-
Notifications
You must be signed in to change notification settings - Fork 508
$BlockedFromReflection instead of name of type #5951
Comments
What's the scenario where the F# tests need this? You're getting (On CoreRT, this is going to actually give you |
This adds a compiler option to disable the behavior that blocks metadata generation for framework implementation details. Enabling the option regresses the size of a Hello world app from 3,891,200 bytes to 5,970,432. We don't want to enable this by default because normal apps have no business in reflecting on the implementation details of the framework. Implementation details vary from version to version and from runtime to runtime. This is likely going to be needed for dotnet#5838 (the CoreFX tests try to access implementation details to test these - we did the work to disable any such tests on UAPAOT, but that's not the flavor of tests we run in CoreRT repo). Fixes dotnet#5951.
The F# testsuite is full of typeof and typedefof operations, even the most basic core test functionality will require it. F# have own metadata for storing details for discriminated union, currying and other things and an internal reflection like mechanism to expose this metadata to the compiler and the developers: F# metadata reflection mechanism (eg.: for discriminated union types, records): https://github.com/Microsoft/visualfsharp/blob/master/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Reflection/FSharpReflection.fs Attributes tests: A "bit" more complex example for type providers: |
I don't really know F# and can't quickly skim these files. Can you point me to the lines that do this kind of things: I would get if they do this: var tp = typeof(Int32);
Console.WriteLine("Name = {0}", tp.Name); This will print What I don't get is why they reflect on the implementation details of the reflection stack: var tp = typeof(Int32).GetType();
Console.WriteLine("Name = {0}", tp.Name); This will print the name of the internal implementation type that reflection uses to represent runtime types (i.e. you're no longer reflecting on Int32, you're reflecting on the reflection stack itself). It will print the same thing no matter what the original |
Quick and Dirty grep output for "GetType()" calls within the testsuite, I hope it will help: Quick and Dirty grep output for "GetType()" calls within the src, I hope it will help: |
I saw those. But those are doing things like What I don't understand is the use case of |
Oh I see. As F# always generalizes the functions to operate as widely as possible on multiple types. The 'T (X in your example) may not yet know by the developer, but will be solved (statically) by the compiler with type inference during the compilation. Yes the Match directly on types: Assert: Also lot's of the time there will no resultsValue in a function the as the result itself will be one or more function constructed based on these typeof: Type based metaprogramming and / or specialization like this (if you define a type in F#, the compiler will automatically generate for you a more or less specialized equality functionality): |
Thank you for the answer. It was general Q. I didn't find any information why it has such behaviour - that's why I opened issue. |
This adds a compiler option to disable the behavior that blocks metadata generation for framework implementation details. Enabling the option regresses the size of a Hello world app from 3,891,200 bytes to 5,970,432. We don't want to enable this by default because normal apps have no business in reflecting on the implementation details of the framework. Implementation details vary from version to version and from runtime to runtime. This is likely going to be needed for #5838 (the CoreFX tests try to access implementation details to test these - we did the work to disable any such tests on UAPAOT, but that's not the flavor of tests we run in CoreRT repo). Fixes #5951.
When I try to do the follow (name for type of some type):
I get the next result:
I guess it has to be
RuntimeType
(at least this result I get when run viadotnet run
)I found the #5838 perhaps it's related.
The text was updated successfully, but these errors were encountered: