Skip to content

Suppresses 0612 warnings when accessing members on obsolete classes - #11738

Open
Morten Nielsen (dotMorten) wants to merge 1 commit into
mainfrom
user/dotmorten/suppress_0612
Open

Suppresses 0612 warnings when accessing members on obsolete classes#11738
Morten Nielsen (dotMorten) wants to merge 1 commit into
mainfrom
user/dotmorten/suppress_0612

Conversation

@dotMorten

@dotMorten Morten Nielsen (dotMorten) commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Fixes

Fixes #10855

PR Type

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no API changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

Description

Previously only obsolete members were suppressed in generated code, but if the entire class is obsolete, a different warning is generated.
This just adds CS0612 to the list of suppressed obsolete warnings, so both obsolete classes and members won't generate obsolete warnings in generated code.

Current Behavior

Only obsolete members are suppressed. If an entire class is obsolete, warnings aren't suppressed.

New Behavior

Both CS0612 and CS0618 gets suppressed.

Customer Impact

Enables ability to have errors-as-warnings enabled. Even if a class isn't actually being actively called by a user, having something like CreateFromString defined causes (unused) code to get generated. Here is one example where they had to suppress all obsolete warnings, risking missing other actual obsolete warnings that do need to be addressed: openclaw/openclaw-windows-node#1179

Regression Potential

  • Low risk — isolated change, limited scope
  • Medium risk — touches shared components or public APIs
  • High risk — architectural or breaking API change

How Has This Been Tested?

  • I have performed a self-review of my own code
  • I have added tests to cover my changes
  • Existing tests pass locally

Previously only suppressed members were suppressed, but if the entire class is obsolete, a different warning is generated.
@dotMorten
Morten Nielsen (dotMorten) requested a review from a team as a code owner September 1, 2026 03:25
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@microsoft-github-policy-service microsoft-github-policy-service Bot added the needs-triage Issue needs to be triaged by the area owners label Sep 1, 2026
@dotMorten

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
1 pipeline(s) were filtered out due to trigger conditions.

@codendone Mike Crider (codendone) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change looks good, but I added one comment to confirm the test passes.

}

[TestMethod]
public void CodeGenerator_ObsoleteWithoutMessageSuppressesCS0612()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It isn't clear if the PR pipeline ran this test. Please confirm the test passes either in the pipeline or when run locally (if the tests in this file aren't running in the pipeline).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-triage Issue needs to be triaged by the area owners

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Code generator generates warnings on obsolete class with CreateFromString attributes

2 participants