-
Notifications
You must be signed in to change notification settings - Fork 695
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
Eliminate obsolete API warnings/errors in product source-build #5496
Conversation
Taking a step back and looking at the source of the problem. Is there any chance of fixing the underlying issue? I see the type is public so maybe not without a breaking change. If not, would it be better to #pragma warning disable/restore the warning in code around the specific instance? The reason I mention this is to avoid the source-build specialization here. |
The ironic thing is that we added these constructor overloads because roslyn CA code analyzers told us to! 🤦 Something else to note is that these constructors & |
Based on the guidance in the breaking change we should be able to add the following:
|
e65b1ef
to
49ed7f4
Compare
Fixed with 49ed7f4 Full source-build validation build is in progress: https://dev.azure.com/dnceng/internal/_build/results?buildId=2308863&view=results |
@@ -14,6 +14,9 @@ public FrameworkException(string message) | |||
{ | |||
} | |||
|
|||
#if NET8_0_OR_GREATER | |||
[Obsolete(DiagnosticId = "SYSLIB0051")] // add this attribute to the serialization ctor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider replaceing the // add this attribute to the serialization ctor
comment with a reference to the breaking change that remove the StreamingContext overload.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Absolutely - this was a simple copy from the guidance doc - will update.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in fcb9c45
I think this should work - it points to the breaking change issue, describing the change and providing guidance for updating source code.
There are more instances, about a dozen. I wonder if we should add a new NoWarn here instead of making all the source changes: NuGet.Client/build/common.project.props Lines 48 to 49 in 7bff223
|
fcb9c45
to
91a235d
Compare
I've updated the PR with conditional obsolete attributes, per guidance in breaking change document: dotnet/docs#34893 |
Thank you for the contribution. However, I don't see any changes to the repo's |
Thank you - will update the description. Implementation has changed based on PR discussion. |
I created a bug report dotnet/roslyn-analyzers#7026. I am also thinking to disable these analyzers from our code analysis ruleset file, remove |
Bug
Fixes: NuGet/Home#12988
Regression? No
Description
When building nuget.client repo in full product source-build we see the following error:
/vmr/src/nuget-client/src/NuGet.Core/NuGet.Frameworks/FrameworkException.cs(17,88): error SYSLIB0051: 'Exception.Exception(SerializationInfo, StreamingContext)' is obsolete: 'This API supports obsolete formatter-based serialization. It should not be called or extended by application code.' (https://aka.ms/dotnet-warnings/SYSLIB0051) [/vmr/src/nuget-client/src/NuGet.Core/NuGet.Frameworks/NuGet.Frameworks.csproj::TargetFramework=net8.0]
To work around this, source-build process have been modifying
Directory.Build.props
during build to add a nowarn for SYSLIB0051. We are moving away from modifying sources during source-build and this needs to be fixed in the repo.This PR adds the conditional
Obsolete
attribute to all affected APIs. Attribute is applicable on .NET 8.0+.