maui icon indicating copy to clipboard operation
maui copied to clipboard

Avoid zero-length array allocations

Open molesmoke opened this issue 1 year ago • 14 comments

Description of Change

Noticed while looking at another issue that CA1825 is configured as an error in .editorconfig, but there are various violations. Pretty minor, but looks like it saves a reasonable number of allocations in some bindings scenarios at least. Thought the blanket fix-all should be reasonable since it should be a non-breaking change.

molesmoke avatar Dec 07 '23 21:12 molesmoke

Hey there @molesmoke! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

ghost avatar Dec 07 '23 21:12 ghost

Maybe the CA1825 warning should be treated as an error

symbiogenesis avatar Dec 08 '23 01:12 symbiogenesis

Does this get rid of all the warnings? If yes, I would indeed say treat this as an error from now on? @hartez?

jfversluis avatar Dec 08 '23 09:12 jfversluis

@jfversluis Yup, this fixes all occurrences - or at least all that I'm aware of :). At the moment its enforcement is limited to Core, but seems reasonable to me that it should be solution-wide.

molesmoke avatar Dec 10 '23 20:12 molesmoke

@jfversluis Seems like I did miss a few 😅 The iOS ones needed a bit of manual effort to fix up

molesmoke avatar Dec 11 '23 08:12 molesmoke

/azp run MAUI-UITests-public

rmarinho avatar Dec 18 '23 12:12 rmarinho

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Dec 18 '23 12:12 azure-pipelines[bot]

/rebase

rmarinho avatar Dec 20 '23 18:12 rmarinho

Does this get rid of all the warnings? If yes, I would indeed say treat this as an error from now on? @hartez?

@jfversluis Yup, this fixes all occurrences - or at least all that I'm aware of :). At the moment its enforcement is limited to Core, but seems reasonable to me that it should be solution-wide.

We should enforce this in all of the projects eventually (we already do in Core). But if we're going to PR a change to fix all the rule violations in a project, we also need to turn on enforcement of the rule for that project (so no new violations creep in).

So at the very least, this PR needs to add editorconfig changes to enforce CA1825 for each other project. I would prefer we do these one project per PR (it makes for a much easier review), but I'd consider taking this if the editorconfig entries were there.

hartez avatar Jan 10 '24 20:01 hartez

@hartez The PR already moves dotnet_diagnostic.CA1825.severity = error to the root editor config:

https://github.com/dotnet/maui/pull/19300/commits/aa84d7c7e5d2937f3ec371cabb40656e10fed8b3

I put it in a separate commit in case the enforcement wasn't wanted (easier to cherry-pick/revert etc.), but I could squash it if you want? I'll rebase in the meantime...

molesmoke avatar Jan 11 '24 21:01 molesmoke

/azp run MAUI-UITests-public

rmarinho avatar Jan 12 '24 12:01 rmarinho

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Jan 12 '24 12:01 azure-pipelines[bot]

🤣🤦🏽‍♂️

Get Outlook for iOShttps://aka.ms/o0ukef


From: azure-pipelines[bot] @.> Sent: Friday, January 12, 2024 9:11:02 PM To: dotnet/maui @.> Cc: Subscribed @.***> Subject: Re: [dotnet/maui] Avoid zero-length array allocations (PR #19300)

Azure Pipelines successfully started running 1 pipeline(s).

— Reply to this email directly, view it on GitHubhttps://github.com/dotnet/maui/pull/19300#issuecomment-1889015365, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AECNY5S7NSDHL6OOMRSZKK3YOER5NAVCNFSM6AAAAABALXP7L2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBZGAYTKMZWGU. You are receiving this because you are subscribed to this thread.Message ID: @.***>

nbaulesglobalsolutions avatar Jan 12 '24 12:01 nbaulesglobalsolutions

@hartez The PR already moves dotnet_diagnostic.CA1825.severity = error to the root editor config:

Sorry, my bad. Somehow I missed that you'd put it at the root.

hartez avatar Jan 12 '24 16:01 hartez