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

[.NET 10] certain [Obsolete] warnings are not reported #76226

Closed
jonathanpeppers opened this issue Dec 2, 2024 · 9 comments · Fixed by dotnet/sdk#45295
Closed

[.NET 10] certain [Obsolete] warnings are not reported #76226

jonathanpeppers opened this issue Dec 2, 2024 · 9 comments · Fixed by dotnet/sdk#45295
Assignees
Labels
Area-Compilers Resolution-External The behavior lies outside the functionality covered by this repository Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented
Milestone

Comments

@jonathanpeppers
Copy link
Member

Version Used: .NET SDK 10.0.100-alpha.1.24573.1

We noticed this from Maestro/codeflow here:

Steps to Reproduce:

  1. Call AppDomain.CreateDomain("test") in .NET 10
  2. Note that you don't get a SYSLIB0024 warning

Repro: testroslyn.zip

Note that this seems to work fine using net9.0 and a .NET 9 SDK.

Diagnostic Id:

SYSLIB0024: 'AppDomain.CreateDomain(string)' is obsolete: 'Creating and unloading AppDomains is not supported and throws an exception.'

Expected Behavior:

I get a SYSLIB0024 warning.

Actual Behavior:

I get no SYSLIB0024 warning.

Other info:

Note that if I open packs\Microsoft.NETCore.App.Ref\10.0.0-alpha.1.24570.9\ref\net10.0\System.Runtime.dll, it looks correct:

Image

The warning also seems to work fine if I declare an [Obsolete] method within the C# file.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Dec 2, 2024
@CyrusNajmabadi
Copy link
Member

I don't know what SYSLIB is. But is isn't roslyn :)

@jonathanpeppers
Copy link
Member Author

jonathanpeppers commented Dec 2, 2024

@CyrusNajmabadi this is if you have [Obsolete(DiagnosticId=" and put SYSLIB0024. Maybe it is any [Obsolete] in a reference assembly?

@jonathanpeppers
Copy link
Member Author

Ok, this works fine, I get a warning if I call it:

[Obsolete]
public void Test()
{
}

This doesn't produce a warning at all:

[Obsolete("whoopsies", DiagnosticId = "SYSLIB0024")]
public void Test()
{
}

@jaredpar jaredpar removed the untriaged Issues and PRs which have not yet been triaged by a lead label Dec 2, 2024
@jaredpar jaredpar assigned jcouv and unassigned AlekseyTs Dec 2, 2024
@jaredpar jaredpar added this to the 17.13 milestone Dec 2, 2024
@jaredpar jaredpar assigned AlekseyTs and unassigned jcouv Dec 2, 2024
@AlekseyTs
Copy link
Contributor

Is it possible that "SYSLIB0024" warning is disabled by default in the new SDK?

@jonathanpeppers What happens if you use a different diagnostic id? For example:

[Obsolete("whoopsies", DiagnosticId = "CustomID_0024")]
public void Test()
{
}

@jonathanpeppers
Copy link
Member Author

When testing this, I found this also produces no warnings:

[Obsolete("whoopsies")]
public void Test()
{
}

What made me notice this issue, warnings related to [SupportedOSPlatformVersion] on Android were also not working in .NET 10. I was hoping whatever the underlying issue was maybe fixed both problems here. [Obsolete] seems more fundamental and reproducible in a console app, though.

@Youssef1313
Copy link
Member

Youssef1313 commented Dec 4, 2024

I investigated this. It's not a Roslyn bug, but an SDK bug. WarningLevel used to align with the .NET version, and the way the SDK does it is using this:

https://github.com/dotnet/sdk/blob/257517e442d17286d450a5641d10302b3f90ed07/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.Analyzers.targets#L64-L65

Now we are two digit version (10) 😄
So, this trick no longer works. Currently on .NET 10, WarningLevel is calculated as 1 which would take out lots of warnings that have higher level. For example, obsoletion warnings have warning level 2

@Youssef1313
Copy link
Member

This is fixed now in SDK and can be closed

@jonathanpeppers
Copy link
Member Author

When Maestro/codeflow makes it to the dotnet/android repo, I'll be able to try it out and close this, thanks!

@AlekseyTs
Copy link
Contributor

@jonathanpeppers I am going to close this issue as fixed. If the problem is still there with updated SDK, please reactivate this issue and attach a complog (https://github.com/jaredpar/complog).

@AlekseyTs AlekseyTs added Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented Resolution-External The behavior lies outside the functionality covered by this repository labels Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers Resolution-External The behavior lies outside the functionality covered by this repository Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants