Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress mgmt track2 analyzer errors without changing generated codes #3486

Closed
archerzz opened this issue Jun 9, 2023 · 3 comments
Closed
Assignees
Labels
Mgmt This issue is related to a management-plane library. Mgmt-EngSys Engineering System (Management Plane Specific)

Comments

@archerzz
Copy link
Member

archerzz commented Jun 9, 2023

Description

As an SDK developer, I'd like to suppress some errors in the generated codes, after reviewing with arch board.

If we apply mgmt track2 analyzer, there will be some errors which we decide we can ignore. Instead of suppressing in project level, we need to figure out how we can suppress in finer grain. Looks like we need an exception list file for each project, like cspell files, which can point to specific model properties or methods, like:

VirtualMachine.Enabled: AZM0016, AZM0017
@archerzz archerzz added Mgmt This issue is related to a management-plane library. Mgmt-EngSys Engineering System (Management Plane Specific) labels Jun 9, 2023
@archerzz archerzz self-assigned this Jun 9, 2023
@archerzz
Copy link
Member Author

archerzz commented Jul 18, 2023

Looks like we don't need to design our own way to suppress errors. After investigation, there are a few options to suppress analyzer errors:

  1. <NoWarn> in .csproj: project scope, granularity is too big
  2. #pragma warning disable: anywhere in codes, not suitable for generated codes
  3. .editorconfig: can be down to .cs file level, but not to each class member
[*.{cs,vb}]
dotnet_diagnostic.<rule-ID>.severity = none
  1. SuppressMessageAttribute in codes: like #pragma
  2. GlobalSuppressions.cs: using SuppressMessageAttribute, but not bound to specific codes. Here is an example from reference.
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes", Scope = "member", Target = "System.Runtime.CompilerServices.StrongBox`1.#System.Runtime.CompilerServices.IStrongBox.Value")]

Option 5 can fulfill our requirement:

  • granularity can be down to each member of a class/struct
  • a single file containing all suppressions, making it easy to maintain

@m-nash ^^

archerzz added a commit to archerzz/azure-sdk-for-net that referenced this issue Aug 1, 2023
- proposed way to change eng props to add mgmt sdk analyzers
- add a example of how to suppress warning

Azure/autorest.csharp#3486
Azure/autorest.csharp#3488
@archerzz
Copy link
Member Author

archerzz commented Aug 15, 2023

Other ways to handle excessive errors:

@archerzz
Copy link
Member Author

By now, GlobalSuppressions.cs is the best way to suppress errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Mgmt This issue is related to a management-plane library. Mgmt-EngSys Engineering System (Management Plane Specific)
Projects
None yet
Development

No branches or pull requests

1 participant