-
Notifications
You must be signed in to change notification settings - Fork 5k
Mark Obsoletions for .NET 5 #39269
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
Mark Obsoletions for .NET 5 #39269
Conversation
I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label. |
src/libraries/Common/tests/TestUtilities/System/Buffers/BoundedMemory.Windows.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/EventLog.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Data.Odbc/src/Common/System/Data/Common/AdapterUtil.Odbc.cs
Outdated
Show resolved
Hide resolved
src/libraries/Microsoft.Win32.SystemEvents/src/Microsoft.Win32.SystemEvents.csproj
Outdated
Show resolved
Hide resolved
src/libraries/Microsoft.Win32.SystemEvents/src/Microsoft.Win32.SystemEvents.csproj
Outdated
Show resolved
Hide resolved
src/libraries/System.Drawing.Common/src/System.Drawing.Common.csproj
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.Xml/src/System/Xml/Serialization/Compilation.cs
Outdated
Show resolved
Hide resolved
src/libraries/Microsoft.Win32.SystemEvents/src/Microsoft.Win32.SystemEvents.csproj
Outdated
Show resolved
Hide resolved
It looks like there are at least a few legitimate test failures from this where compensating changes need to be made for the obsoleted APIs. I'll look at those later this morning. |
...braries/System.DirectoryServices/src/System/DirectoryServices/DirectoryServicesPermission.cs
Outdated
Show resolved
Hide resolved
...ystem.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TraceLoggingEventSource.cs
Show resolved
Hide resolved
@@ -145,6 +145,9 @@ public sealed override AssemblyName[] GetReferencedAssemblies() | |||
|
|||
// Miscellaneous properties | |||
public sealed override bool ReflectionOnly => true; | |||
#if !FEATURE_GAC |
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.
Can this be applied unconditionally? (Same as my other comment.)
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.
I think this one needs to remain conditional because we build this for netcoreapp3.0
and netstandard2.0
too.
@steveharter - Can you confirm that I need this #ifdef
to apply [Obsolete]
to RoAssembly.GlobalAssemblyCache
only in net5.0
+ only?
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.
I see no reason to have the condition. MetadataLoadContext doesn't provide a way to "resolve" an assembly from the GAC (even if running under .NET Framework) so this will always be false
.
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.
Thanks. I ended up finding it does still need to be conditional, since the DiagnosticId and UrlFormat properties are new in net5.0 and this compiles against lower versions. I'm going to change the logic to be #if GAC_OBSOLETIONS
though, so it connotes the reasoning more clearly.
src/libraries/System.Security.Permissions/ref/System.Security.Permissions.Forwards.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Security.Permissions/src/System/Security/Permissions/Obsoletions.cs
Outdated
Show resolved
Hide resolved
Thanks -- I didn't know that. The suggestion makes more sense to me now. This is intriguing and worth further consideration, but it was called out as a non-goal in the better obsoletion doc. Would it be OK with you if we moved this PR forward but then I submit an issue for us to consider down-leveling the obsoletions to netstandard2.0 in a separate issue, @ericstj? @GrabYourPitchforks - I've addressed all of your feedback -- thanks for checking so many details! |
Yes, this should be done as follow up - if we decide that it is the right thing to do. |
src/libraries/System.Security.Permissions/src/System/Security/SecurityManager.cs
Show resolved
Hide resolved
Yeah I’m ok with that. Folks need to consider how that non-goal plays out in practice to understand what makes the most sense. |
@GrabYourPitchforks - I found a regression where we had code calling into [Obsolete(Obsoletions.ConstrainedExecutionRegionMessage, DiagnosticId = Obsoletions.ConstrainedExecutionRegionDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
public static void ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, object? userData)
{
if (code == null)
throw new ArgumentNullException(nameof(code));
if (backoutCode == null)
throw new ArgumentNullException(nameof(backoutCode));
bool exceptionThrown = true;
try
{
code(userData);
exceptionThrown = false;
}
finally
{
backoutCode(userData, exceptionThrown);
}
} I'm considering removing the obsolete attribute from it and reverting the change where we removed the call to it. What do you think? |
In .NET Framework, the implementation of this method made guarantees about how this code could execute within CERs. The implementation was, roughly: PrepareDelegate(tryMethod);
PrepareDelegate(finallyMethod);
PrepareConstrainedRegions();
try
{
tryMethod(userData);
}
finally
{
finallyMethod(userData);
} In .NET Core, since CER guarantees cannot be made, it's still a good idea to mark the method as obsolete in the sense of "this method doesn't do what you think it does." |
The only check failing is because of the following, which is unrelated to these changes and has been failing on other PRs as well.
|
@ericstj I filed https://github.com/dotnet/designs/issues/145 for consider the downlevel obsoletion for OOB package APIs. |
Well shoot -- it appears I somehow missed the "Classes that derive from CodeAccessSecurityAttribute" category. I'll submit a follow-up PR for those. |
* Mark new obsoletions for .NET 5; update existing obsoletions * Exclude DirectoryServicesPermission/DirectoryServicesPermissionAttribute from obsoletions for now * No need to restore SYSLIB0003 at end of Forwards files * Use a common Obsoletions.cs file for all SYSLIB obsoletions * Resurrect CER code behind #ifdef in EventSource * Mark GlobalAssemblyCache overrides as Obsolete * Suppress Thread.Abort() error in ImageAnimator.Unix.cs * Unconditionally mark RoAssembly.GlobalAssemblyCache as obsolete * Rename MSLIB0001 to SYSLIB0001 in ref assembly * Suppress obsoletion warnings in tests * Adopt a uniform #ifdef for NET50_OBSOLETIONS * Fix BinaryFormatter obsoletion message after the rebase * Use SYSTEM_PRIVATE_CORELIB constant instead of NETCOREAPP * Remove the code comment on the ifdef * Apply feedback related to CER obsoletions * Apply feedback related to CAS * Update ref assembly to reflect SecurityManager obsoletion * Fix regression in System.IO.Pipes.NamedPipeServerStream.Windows.RunAsClient
dotnet/docs#20894 submitted for the breaking change document. |
This contributes the remaining obsoletions from dotnet/designs#139.
SYSLIB0003
- Code Access Security is not supported or honored by the runtime.SYSLIB0004
- The Constrained Execution Region (CER) feature is not supported.SYSLIB0005
- The Global Assembly Cache is not supported.SYSLIB0006
- Thread.Abort is not supported and throws PlatformNotSupportedException.SYSLIB0007
- The default implementation of this cryptography algorithm is not supported.SYSLIB0008
- The CreatePdbGenerator API is not supported and throws PlatformNotSupportedException.SYSLIB0009
- The AuthenticationManager Authenticate and PreAuthenticate methods are not supported and throw PlatformNotSupportedException.SYSLIB0010
- This Remoting API is not supported and throws PlatformNotSupportedException.Existing obsoletions were updated to reflect the diagnostic id prefix of
SYSLIB
.BinaryFormatter
was moved toSYSLIB0011
.