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

Mark Obsoletions for .NET 5 #39269

Merged
merged 18 commits into from
Jul 18, 2020
Merged

Mark Obsoletions for .NET 5 #39269

merged 18 commits into from
Jul 18, 2020

Conversation

jeffhandley
Copy link
Member

@jeffhandley jeffhandley commented Jul 14, 2020

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 to SYSLIB0011.

@Dotnet-GitSync-Bot
Copy link
Collaborator

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.

@jeffhandley jeffhandley marked this pull request as draft July 14, 2020 13:05
@jeffhandley jeffhandley changed the title Mark Constrained Execution Region and Global Assembly Cache as Obsolete Mark Obsoletions for .NET 5 Jul 15, 2020
@jeffhandley jeffhandley requested a review from jkotas July 15, 2020 12:05
@jeffhandley jeffhandley marked this pull request as ready for review July 15, 2020 12:06
@jeffhandley
Copy link
Member Author

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.

@@ -145,6 +145,9 @@ public sealed override AssemblyName[] GetReferencedAssemblies()

// Miscellaneous properties
public sealed override bool ReflectionOnly => true;
#if !FEATURE_GAC
Copy link
Member

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.)

Copy link
Member Author

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?

Copy link
Member

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.

Copy link
Member Author

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.

@jeffhandley
Copy link
Member Author

If the types and members are defined in netstandard then forwarded in netframework then a netframework app would never see the attributes nor warnings. A netstandard library would warn that library author appropriately.

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!

@jkotas
Copy link
Member

jkotas commented Jul 17, 2020

Would it be OK with you if we moved this PR forward

Yes, this should be done as follow up - if we decide that it is the right thing to do.

@ericstj
Copy link
Member

ericstj commented Jul 17, 2020

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.

@jeffhandley
Copy link
Member Author

@GrabYourPitchforks - I found a regression where we had code calling into RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup, where I'd removed that call but removing that call changed the behavior of the code. I pushed a commit that replicated the behavior that method provided and it fixed the regression, but I'm now second-guessing whether or not we should obsolete that helper method.  I don't actually see any CER logic in it.

        [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?

@GrabYourPitchforks
Copy link
Member

ExecuteCodeWithGuaranteedCleanup call sites shouldn't be removed, since the code has a side effect. Instead, the call sites should be changed to use normal try / finally semantics instead of using this helper routine.

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."

@jeffhandley
Copy link
Member Author

The only check failing is because of the following, which is unrelated to these changes and has been failing on other PRs as well.

Assertion failed '!foundDiff' in 'OpenSsl:GetSslError(Microsoft.Win32.SafeHandles.SafeSslHandle,int,byref):int' during 'Linear scan register alloc' (IL size 99)

@jeffhandley jeffhandley merged commit 329f0db into dotnet:master Jul 18, 2020
@jeffhandley
Copy link
Member Author

@ericstj I filed https://github.com/dotnet/designs/issues/145 for consider the downlevel obsoletion for OOB package APIs.

@jeffhandley
Copy link
Member Author

Well shoot -- it appears I somehow missed the "Classes that derive from CodeAccessSecurityAttribute" category. I'll submit a follow-up PR for those.

@jeffhandley jeffhandley deleted the net5-obsoletions branch July 19, 2020 20:48
@jeffhandley jeffhandley added this to the 5.0.0 milestone Jul 20, 2020
@jeffhandley jeffhandley added the breaking-change Issue or PR that represents a breaking API or functional change over a prerelease. label Jul 23, 2020
@danmoseley danmoseley added the needs-breaking-change-doc-created Breaking changes need an issue opened with https://github.com/dotnet/docs/issues/new?template=dotnet label Jul 30, 2020
Jacksondr5 pushed a commit to Jacksondr5/runtime that referenced this pull request Aug 10, 2020
* 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
@jeffhandley
Copy link
Member Author

dotnet/docs#20894 submitted for the breaking change document.

@jeffhandley jeffhandley removed the needs-breaking-change-doc-created Breaking changes need an issue opened with https://github.com/dotnet/docs/issues/new?template=dotnet label Oct 3, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Meta breaking-change Issue or PR that represents a breaking API or functional change over a prerelease.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants