Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

ApiCompat - Add CAS Stubs - #10049

Closed
ioanacrant wants to merge 3 commits into
dotnet:masterfrom
ioanacrant:cas-stub
Closed

ioanacrant wants to merge 3 commits into
dotnet:masterfrom
ioanacrant:cas-stub

Conversation

@ioanacrant

Copy link
Copy Markdown
Contributor
  • Creates System.Security.Permissions contract
  • Adds types (and their members) that were in Xamarin but not .NET Core from namespaces System.Security, System.Security.Permissions, System.Security.Policy
  • Added basic method tests

Resolves #9482
@danmosemsft @ellismg

@@ -0,0 +1,6 @@
namespace System

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

These are types we expect to live in a lower contract but aren't there yet? If so, I think it'd be worth adding a TODO comment, ideally that includes the relevant GitHub issue number.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

+1. FWIW @Lixire is working on adding this API back as we type.

@stephentoub

Copy link
Copy Markdown
Member

Thanks, @ioanacrant. Nice job getting through all of this.

Comment thread pkg/descriptions.json
]
},
{
"Name": "System.Security.Permissions",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There's more than CAS in this package, so this description is overly specific to the point of being misleading.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I wrote this, happy if domain experts have better word-smiting.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Do we have a standard way of discouraging use of a package? People really shouldn't use this for anything other than making old code compile/run given that it doesn't implement anything.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@terrajobst Can you craft a better description for us here?

@ellismg

ellismg commented Jul 20, 2016

Copy link
Copy Markdown
Contributor

Ioana and I spent some time looking at the comment out members to understand what would need to be done to uncomment them. I think there's a good amount of work to do it.

First off, I noticed that ZoneIdentityPermission.Union was commented out but it should be able to be added back now (Ioana, I expect this was just some fat fingering on my part when I first generated the contract).

The remaining APIs are blocked because of the following types:

  • System.Security.SecurityElement
  • System.Threading.AsyncFlowControl
  • System.ApplicationIdentity
  • The Serialization types.

For SecurityElement, AsyncFlowControl and ApplicationIdentity we first need to understand how we are going to bring back these types. Are we going to add dummy implementations in .NET Core or are we going to try to expose them from mscorlib and facade over them?

For ApplicationIdentity, I believe that we'll need to expose it from mscorlib (since AppDomain exposes it and we don't want to run into type identity issues) but there's a question about what it should actually do. The current implementation is related to click once (and in fact is not even present in the untrimmed System.Private.Corelib.dll in CoreCLR, as it's guarding by FEATURE_CLICKONCE which is not defined), so there needs to be work done in CoreCLR to provide an implementation (e.g we can't just edit model.xml and expose it "for free").

A quick glance at AsyncFlowControl and SecurityElement lead me to believe that we could provide dummy implementations in CoreFX. AsyncFlowControl's implementation in the CLR is conditional on FEATURE_CORECLR not being defined, so it's not straightforward to just expose that. SecurityElement is in a similar bucket. Note that for both of the types the proposed factoring we have has them in different assemblies, so we would be blocked on adding them back until we get contract updates for dev/API going.

Serialization is another ball of mud that needs to be untangled. I expect that we need to expose SeralizationInfo, StreamingContext, ISerializable and friends from mscorlib for type identity reasons, but the current implementations in dotnet/coreclr are guarded by FEATURE_SERIALIZATION so we again need to decide how to bring them back. It's not a simple edit to model.xml to do so.

I think we really need to consider filing follow up bugs for the types I've identified and have the work items that bring them back pay down the small amount of debt here in CAS. That work should be parallelizable. If we really want to hold this, we'll need to land a work across multiple contracts before we can uncomment these members, or decide to do throw away work here providing dummy implementations in this contract which would have to be cleaned up later. I really don't think we should be spinning our wheels on that.

@stephentoub I'm interested in what you think about this.

@stephentoub

Copy link
Copy Markdown
Member

A quick glance at AsyncFlowControl and SecurityElement lead me to believe that we could provide dummy implementations in CoreFx

I expect they'd need to be provided in CoreCLR, as ExecutionContext.SuppressFlow returns an AsyncFlowControl, and we'd need the type identities to match (assuming ExecutionContext.SuppressFlow is coming back as well). That's also one where we may want/need to do something more that a dummy/nop implementation, as there is currently state that gets flown that this could suppress, e.g. AsyncLocal. cc: @ericeil, @kouvel

Serialization is another ball of mud that needs to be untangled. I expect that we need to expose SeralizationInfo, StreamingContext, ISerializable and friends from mscorlib for type identity reasons, but the current implementations in dotnet/coreclr are guarded by FEATURE_SERIALIZATION so we again need to decide how to bring them back. It's not a simple edit to model.xml to do so.

Yes, we're going to need to do that anyway. In #10144 I added BinaryFormatter to corefx, but it's using corefx implementations of those types, which means that it can't properly serialize types defined in mscorlib with custom serialization, as those types end up using different identities of these types. I disabled serialization for the offending types in mscorlib with dotnet/coreclr#6263, but that was just a temporary bandaid until we actually split apart FEATURE_SERIALIZATION and get this infrastructure exposed.

I think we really need to consider filing follow up bugs for the types I've identified and have the work items that bring them back pay down the small amount of debt here in CAS. That work should be parallelizable

I'm fine with that.

@danmoseley

Copy link
Copy Markdown

I agree that this has value as it is (with other feedback addressed) and Ioana should commit it and open issues for the loose ends.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.