-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Remove InternalsVisibleTo and Microsoft.Internals from S.ComponentModel.Composition #35148
Remove InternalsVisibleTo and Microsoft.Internals from S.ComponentModel.Composition #35148
Conversation
@MichalStrehovsky currently 300 tests are failing out of 1100 on uapaot. These are the unique PNSEs: PlatformNotSupportedException : AssemblyName.GetAssemblyName() is not supported on this platform. I need to dig deeper what exactly the reason for the "Operation is not supported on this platform." is. Is the Assembly.GetAssemblyName() expected and is there a workaround for it? EDIT: attaching the test log |
This is the flavor of the API that cracks open the file with the specified name and computes an I really wonder what S.CM does with that. Whatever it's doing probably won't be compatible with the single-file deployment that is coming to .NET Core. |
OK. One of the operation is not supported messages is because it tries to access EDIT:
Also using the AssemblyCatalog to load it:
|
The Reflection.Emit PNSEs are because of the MetadataViewGenerator which uses AssemblyBuilder: https://github.com/dotnet/corefx/blob/master/src/System.ComponentModel.Composition/src/System/ComponentModel/Composition/MetadataViewGenerator.cs#L85 |
Other NullReferenceException are because of these static reflection calls: Line 12 in c06df8e
|
I think I'll let @swaroop-sridhar solve this as part of dotnet/designs#52 :).
We need to make the classes/methods this is reflecting on public in the implementation and the problem will go away (we've done similar things in System.Linq.Expressions and Microsoft.CSharp). |
And add them to the corresponding rd.xml, right? |
I think the ProjectN reflection analyzer should be able to get this right once this is no longer reflection blocked as an internal implementation detail. |
You are right that we have used this workaround for ProjectN in the core framework, but we very much dislike it. S.ComponentModel.Composition should be rather marked as user assembly to make this work. |
What does this do to test code coverage? |
With changes+-----------------------------------+--------+--------+--------+ Without changes85.2% | | | | 81.3% I can probably get the number higher with a bit more time (without using reflection). |
How would I do that? Does that mean that the assembly won't be assembly blocked? |
By adding Same reflection rules will apply as for user code (so you can reflect on anything). It's worth trying out. One problem with that is that the reflection information becomes pay for play and we don't automatically reflection enable everything in the framework assemblies. Reflection use that we didn't predict will lead to exceptions. Blocked types have a special reflection experience (pretend type has no methods, or fields, pretend the type is not generic, pretend the name is a GUID, etc.). Reflection unblocked types without metadata just throw. |
This is always a bad idea. It leaves you with tests that hit the internal APIs but you lose all edit-time and compile-time assistance related to locating them (IDE navigation tools, refactoring tools, etc.). |
FWIW, it does not make it always a bad idea. It makes it a trade-off. |
@ViktorHofer what's status of this PR? Looks like no update in last 3 weeks ... |
I plan to finish this sometime next week. |
@ViktorHofer looks like you did not have time. Can we close it for the time being. We can reopen once you have time again ... |
1 month no update, let's close it for now - feel free to reopen it once you have time to come back to it. Thanks! |
Sure. No prob. |
I suggest to turn off white-space changes when reviewing this PR.
I disabled all the tests rely on internals. I either commented out code paths or excluded the files from the project but didn't delete those code paths. Somebody could try to re-enable some of the tests with reflection calls.