Get rid of reflection blocked types (#85810)
authorMichal Strehovský <MichalStrehovsky@users.noreply.github.com>
Mon, 8 May 2023 06:34:59 +0000 (15:34 +0900)
committerGitHub <noreply@github.com>
Mon, 8 May 2023 06:34:59 +0000 (15:34 +0900)
commit05a3d360d6079db3cb64636fcdf99f832a58c1d2
treee47392c69cd44e50e66a6855c2ead71770d8347f
parent5f0d620cae0649dfb56babf6603cb4190f65c3bd
Get rid of reflection blocked types (#85810)

Fixes #72570.

Still need to delete workarounds that make things public in corelib but maybe this diff is large enough already?

We were gradually getting less and less from reflection blocking:

* We stopped blocking things outside corelib (.NET Native blocked all of BCL; we don't).
* We trim reflection metadata and that allows us to have method bodies without metadata.

With this, we should be able to get type definition-level reflection metadata for any MethodTable there is in the system.

This is a ~30 kB size regression for BasicMinimalApis. It is pretty much a wash for Hello World, because all the BCL cruft to handle reflection blocked types costs as much as the benefit of blocking.
82 files changed:
eng/testing/tests.singlefile.targets
src/coreclr/nativeaot/Common/src/System/Runtime/CompilerServices/__BlockAllReflectionAttribute.cs [deleted file]
src/coreclr/nativeaot/Common/src/System/Runtime/CompilerServices/__BlockReflectionAttribute.cs [deleted file]
src/coreclr/nativeaot/System.Private.CoreLib/src/CompatibilitySuppressions.xml
src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/DeveloperExperience/DeveloperExperience.cs
src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Reflection/Augments/ReflectionAugments.cs
src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Reflection/Core/AssemblyBinder.cs
src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Reflection/Core/Execution/ExecutionDomain.cs
src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Reflection/Core/Execution/ExecutionEnvironment.cs
src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Reflection/Core/Execution/FieldAccessor.cs
src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Reflection/Core/Execution/MethodInvoker.cs
src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Reflection/Core/Execution/ReflectionCoreExecution.cs
src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Reflection/Core/NonPortable/RuntimeTypeUnifier.cs
src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Reflection/Core/ReflectionDomainSetup.cs
src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Runtime/Augments/ReflectionExecutionDomainCallbacks.cs
src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Runtime/Augments/RuntimeAugments.cs
src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Runtime/Augments/StackTraceMetadataCallbacks.cs
src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Runtime/Augments/TypeLoaderCallbacks.cs
src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Runtime/CompilerServices/FunctionPointerOps.cs
src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Runtime/CompilerServices/GenericMethodDescriptor.cs
src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Runtime/CompilerServices/OpenMethodResolver.cs
src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Diagnostics/DebugAnnotations.cs
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Diagnostics/DebuggerGuidedStepThroughAttribute.cs
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/AssemblyRuntimeNameHelpers.cs
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/BinderBundle.cs
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/DynamicInvokeInfo.cs
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/EnumInfo.cs
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/General/BlockedRuntimeTypeNameGenerator.cs [deleted file]
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/General/MetadataReaderExtensions.NativeFormat.cs
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/General/MetadataReaderExtensions.cs
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/General/QHandles.cs
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/General/QSignatureTypeHandle.cs
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/General/TypeResolver.NativeFormat.cs
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/General/TypeUnifier.cs
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/TypeInfos/RuntimeBlockedTypeInfo.cs [deleted file]
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/TypeInfos/RuntimeConstructedGenericTypeInfo.cs
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/TypeInfos/RuntimeTypeInfo.CoreGetDeclared.cs
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/CompilerServices/ReflectionBlockedAttribute.cs [deleted file]
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.NativeAot.cs
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/InteropExtensions.cs
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/RuntimeImports.cs
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/TypeLoaderExports.cs
src/coreclr/nativeaot/System.Private.CoreLib/src/System/RuntimeExceptionHelpers.cs
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/Condition.cs
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/Lock.cs
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/LockHolder.cs
src/coreclr/nativeaot/System.Private.DisabledReflection/src/Internal/Reflection/ReflectionExecutionDomainCallbacksImplementation.cs
src/coreclr/nativeaot/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/ExecutionEnvironmentImplementation.MappingTables.cs
src/coreclr/nativeaot/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/ExecutionEnvironmentImplementation.Runtime.cs
src/coreclr/nativeaot/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/PayForPlayExperience/DiagnosticMappingTables.cs [deleted file]
src/coreclr/nativeaot/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/PayForPlayExperience/MissingMetadataExceptionCreator.cs
src/coreclr/nativeaot/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/ReflectionExecution.cs
src/coreclr/nativeaot/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/ReflectionExecutionDomainCallbacksImplementation.cs
src/coreclr/nativeaot/System.Private.Reflection.Execution/src/System.Private.Reflection.Execution.csproj
src/coreclr/nativeaot/System.Private.StackTraceMetadata/src/System.Private.StackTraceMetadata.csproj
src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/LowLevelStringConverter.cs
src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/MetadataReaderHelpers.cs [deleted file]
src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.Metadata.cs
src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.MetadataSignatureParsing.cs
src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/TypeSystem/RuntimeNoMetadataType.cs
src/coreclr/nativeaot/System.Private.TypeLoader/src/System.Private.TypeLoader.csproj
src/coreclr/tools/Common/Compiler/DependencyAnalysis/SortableDependencyNode.cs
src/coreclr/tools/Common/Internal/Metadata/NativeFormat/Generator/CsWriter.cs
src/coreclr/tools/Common/Internal/Metadata/NativeFormat/NativeFormatReaderCommonGen.cs
src/coreclr/tools/Common/Internal/Metadata/NativeFormat/NativeFormatReaderGen.cs
src/coreclr/tools/Common/Internal/Metadata/NativeFormat/NativeMetadataReader.cs
src/coreclr/tools/Common/Internal/Runtime/MetadataBlob.cs
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/BlockedInternalsBlockingPolicy.cs [deleted file]
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/BlockReflectionTypeMapNode.cs [deleted file]
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CanonicalEETypeNode.cs
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ConstructedEETypeNode.cs
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/DefaultConstructorMapNode.cs [deleted file]
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/EETypeNode.cs
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/GeneratingMetadataManager.cs
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/MetadataManager.cs
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UsageBasedMetadataManager.cs
src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj
src/coreclr/tools/aot/ILCompiler/ILCompilerRootCommand.cs
src/coreclr/tools/aot/ILCompiler/Program.cs
src/libraries/System.Private.CoreLib/src/System/Text/Latin1Encoding.cs
src/tests/nativeaot/SmokeTests/TrimmingBehaviors/DeadCodeElimination.cs