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

Obsolete PrincipalPermissionAttribute ctor as error #37536

Merged
merged 3 commits into from
Jun 18, 2020

Conversation

GrabYourPitchforks
Copy link
Member

Resolves #36972.
Resolves #31279.

Source breaking change, not a runtime breaking change. (We didn't change the behavior of the APIs.)

/cc @terrajobst for the diagnostic ids and "better obsoletion" stuff.

@GrabYourPitchforks GrabYourPitchforks added area-System.Security breaking-change Issue or PR that represents a breaking API or functional change over a prerelease. labels Jun 6, 2020
@GrabYourPitchforks GrabYourPitchforks added this to the 5.0 milestone Jun 6, 2020
@ghost
Copy link

ghost commented Jun 6, 2020

Tagging subscribers to this area: @bartonjs, @vcsjones, @krwq
Notify danmosemsft if you want to be subscribed.

@@ -1128,6 +1128,9 @@ public sealed partial class PrincipalPermission : System.Security.IPermission, S
[System.AttributeUsageAttribute(System.AttributeTargets.Class | System.AttributeTargets.Method, AllowMultiple=true, Inherited=false)]
public sealed partial class PrincipalPermissionAttribute : System.Security.Permissions.CodeAccessSecurityAttribute
{
#if CAS_OBSOLETIONS
[System.ObsoleteAttribute("PrincipalPermissionAttribute is not honored by the runtime and must not be used.", true, DiagnosticId = "BCL0002", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
Copy link
Member

Choose a reason for hiding this comment

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

Do we have the destination already created? We should ensure this is all in place before the first Preview this is contained in is released.

Copy link
Member Author

Choose a reason for hiding this comment

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

Right now it redirects to #36972, pending final location of where the guidance doc will be.

@@ -1128,6 +1128,9 @@ public sealed partial class PrincipalPermission : System.Security.IPermission, S
[System.AttributeUsageAttribute(System.AttributeTargets.Class | System.AttributeTargets.Method, AllowMultiple=true, Inherited=false)]
public sealed partial class PrincipalPermissionAttribute : System.Security.Permissions.CodeAccessSecurityAttribute
{
#if CAS_OBSOLETIONS
[System.ObsoleteAttribute("PrincipalPermissionAttribute is not honored by the runtime and must not be used.", true, DiagnosticId = "BCL0002", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
Copy link
Member

Choose a reason for hiding this comment

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

How/where are we tracking the distribution/assignment of BCL#### IDs?

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 tried cataloging them in a single place as part of #37535. The idea was that this file would be included in every project we compile. However, since the IL linker "trim" step doesn't run over every project, it ended up including the internal class in every library we built. :(

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 added a markdown file to act as a centralized list. Does this help?

{
PrincipalPermissionAttribute ppa = new PrincipalPermissionAttribute(new Permissions.SecurityAction());
IPermission ip = ppa.CreatePermission();
}
Copy link
Member

Choose a reason for hiding this comment

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

Since existing binaries will continue to work, seems valuable to continue to validate the behavior. Do we not have any way to write the test given the error obsoletion?

Copy link
Member

Choose a reason for hiding this comment

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

Could put a test binary in the test data repo (where we put compression test data)?

Copy link
Member Author

Choose a reason for hiding this comment

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

These methods quite literally no-op. If you attempt to use them for real you'll get a NullReferenceException. IMO this test (and the tests for FileIOPermissionAttribute, etc.) isn't testing anything useful.

Copy link
Member Author

Choose a reason for hiding this comment

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

If there's really a desire to keep this test, we could always Activator.CreateInstance it, since that won't produce the build error. But again, since the implementations are no-ops, I'm not sure what utility such a test has.

I'll defer to your collective judgment if you feel that such a test is useful. :)

@GrabYourPitchforks
Copy link
Member Author

crossgen2 CI failure is #37732
mono System.Drawing.Common CI failure is #37838

@GrabYourPitchforks
Copy link
Member Author

@bartonjs, @safern, does bcd6662 address your concerns?

@safern
Copy link
Member

safern commented Jun 17, 2020

Yep, that looks correct.

@GrabYourPitchforks
Copy link
Member Author

Thank you both for the eagle-eyed catch! :)

@GrabYourPitchforks GrabYourPitchforks merged commit 997539e into dotnet:master Jun 18, 2020
@GrabYourPitchforks GrabYourPitchforks deleted the obs_ppa branch June 18, 2020 01:57
@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-System.Security 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.

PrincipalPermissionAttribute ctor should be obsolete as error Non-support of PrincipalPermissionAttribute
5 participants