WiseTechGlobal / WTG.Analyzers

Analyzers from WiseTech Global to enforce our styles, behaviours, and prevent common mistakes.
Other
15 stars 3 forks source link

WTG1001:DoNotUsePrivateKeyword should ignore partial methods with non-void return types #220

Closed wtg-mg8 closed 1 month ago

wtg-mg8 commented 1 month ago

WTG1001:Do not use the 'private' keyword analyzer is raising a diagnostic for partial methods to remove the private accessibility modifier when doing so causes the compiler to emit error CS8796: Partial method must have accessibility modifiers because it has a non-void return type.

Given the following class

partial class Testing
{
    [GeneratedRegex("abc|def", RegexOptions.IgnoreCase, "en-US")]
    static partial System.Text.RegularExpressions.Regex AbcOrDefGeneratedRegex();
}

Compiler will error: CS8796: Partial method 'Testing.AbcOrDefGeneratedRegex()' must have accessibility modifiers because it has a non-void return type.

Expected outcome: WTG1001 analyzer should not prompt to remove private from non-void return partial methods.

Forgot to mention: this was raised to me by Oleh Miroshnychenko (@oleh-wtg).

Corresponds to WI00764889

yaakov-h commented 1 month ago

Duplicate of #205.

We already have unit tests and logic that account for this:

This was fixed in #206 which shipped in WTG.Analyzers package version 3.7.2.

If you're still using an older analyzers version I suggest updating. 😉

oleh-wtg commented 1 month ago

[like] Oleh Miroshnychenko reacted to your message:


From: Yaakov @.> Sent: Monday, July 1, 2024 8:20:45 AM To: WiseTechGlobal/WTG.Analyzers @.> Cc: Oleh Miroshnychenko @.>; Mention @.> Subject: Re: [WiseTechGlobal/WTG.Analyzers] WTG1001:DoNotUsePrivateKeyword should ignore partial methods with non-void return types (Issue #220)

You don't often get email from @.*** Learn why this is importanthttps://aka.ms/LearnAboutSenderIdentification âš  CAUTION: This email originated from outside of the organisation. Do not click on links or open attachments in emails unless you are sure it is from a trusted sender and was expected.

Duplicate of #205https://github.com/WiseTechGlobal/WTG.Analyzers/issues/205.

We already have unit tests and logic that account for this:

This was fixed in #206https://github.com/WiseTechGlobal/WTG.Analyzers/pull/206 which shipped in WTG.Analyzers package version 3.7.2.

If you're still using an older analyzers version I suggest updating. 😉

— Reply to this email directly, view it on GitHubhttps://github.com/WiseTechGlobal/WTG.Analyzers/issues/220#issuecomment-2199531909, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BDHSNMRGVZBM5BPFS3MVJ3TZKEGN3AVCNFSM6AAAAABJ67G7EGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOJZGUZTCOJQHE. You are receiving this because you were mentioned.Message ID: @.***>