Skip to content
This repository was archived by the owner on Sep 25, 2026. It is now read-only.
This repository was archived by the owner on Sep 25, 2026. It is now read-only.

[feature/damAnalyzer] Integrate DAM analyzer feature branch into main #2580

Closed

Description

@sbomer

#2523 is adding a test run to check that there are no extra warnings produced by the analyzer. The list of test failures so far is below, along with an initial triage. I created a few new dedicated issues for tracking purposes.

Issues blocking integration to main

Note: this does not include tests which are currently skipped, such as the LinkAtributes tests - I will update the list to include those once I run the skipped tests in the "no extra warnings" mode.


Tests failing in #2523

  • ReflectionTests.MembersUsedViaReflection [FAIL]
    unsupported intrinsic: GetMember with binding flags
  • ReflectionTests.TypeUsedViaReflection [FAIL]
    RUC on GetType
  • ReflectionTests.FieldsUsedViaReflection [FAIL]
    unsupported intrinsic binding flags
  • ReflectionTests.ExpressionNewType [FAIL]
    RUC on GetType
  • ReflectionTests.ConstructorsUsedViaReflection [FAIL]
    unsupported intrinsic: GetConstructors with binding flags
  • ReflectionTests.EventsUsedViaReflection [FAIL]
    unsupported intrinsic: GetEvents with binding flags
  • ReflectionTests.ActivatorCreateInstance [FAIL]
    RUC on CreateInstance
  • ReflectionTests.ExpressionCallString [FAIL]
    RUC on Expression.Call
  • ReflectionTests.TypeUsedViaReflectionTypeDoesntExist [FAIL]
    RUC on Type.GetType
  • ReflectionTests.ExpressionPropertyMethodInfo [FAIL]
    RUC on Expression.Property
  • ReflectionTests.AssemblyImportedViaReflectionWithSweptReferences [FAIL]
    RUC on Type.GetType
  • ReflectionTests.MethodsUsedViaReflection [FAIL]
    unsupported intrinsic: Type.GetMethods with binding flags
  • ReflectionTests.TypeHierarchySuppressions [FAIL]
    unsupported intrinsic: GetType call on instance, where type has DAM,
    and we don't look for DAM on type
  • ReflectionTests.ConstructorUsedViaReflection [FAIL]
    unsupported intrinsic: GetConstructors with binding flags
  • ReflectionTests.PropertiesUsedViaReflection [FAIL]
    unsupported intrinsic: GetProperties with binding flags
  • ReflectionTests.NestedTypesUsedViaReflection [FAIL]
    unsupported intrinsic: GetNestedTypes with binding flags
  • ReflectionTests.MemberUsedViaReflection [FAIL]
    unsupported intrinsic: Type.GetMember with binding flags
  • ReflectionTests.ObjectGetType [FAIL]
    unsupported intrinsic: object.GetType
  • ReflectionTests.TypeHierarchyReflectionWarnings [FAIL]
    unsupported intrinsic: object.GetType
  • UnreachableBlockTests.TryFilterBlocks [FAIL]
    no support for filter regions
  • LoggingTests.SourceLines [FAIL]
    is OK, test infra doesn't support ExpectedWarning with SourceLine
  • AdvancedTests.TypeCheckRemoval [FAIL]
    no support for filter regions
  • TestFrameworkTests.VerifyResourceInAssemblyAttributesBehavior [FAIL]
    test infra problem (needs investigation)
  • TestFrameworkTests.CanSandboxDependenciesUsingType [FAIL]
    test infra problem (needs investigation)
  • Warnings.WarningSuppressionTests.SuppressWarningsInMembersAndTypesUsingTarget
    warning suppressions in code using Target = "..." syntax
  • Warnings.WarningSuppressionTests.SuppressWarningsInCompilerGeneratedCode
    extra warnings in analyzer, needs investigation
  • Warnings.WarningSuppressionTests.SuppressWarningsViaXml
    analyzer needs to support XML attributes

@agocke hopefully this helps track things - let me know if you want me to adjust anything.

Activity

  1. sbomer commented on Feb 11, 2022

    @sbomer
    MemberAuthor

    @tlakollo and I looked at warnings produced by the analyzer on dotnet/runtime. Before disabling intrinsics:

    src/libraries/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComponentActivator.cs(142,44): error IL2026: Using member 'Internal.Runtime.InteropServices.ComponentActivator.InternalGetFunctionPointer(AssemblyLoadContext, String, String, IntPtr)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Native hosting is not trim compatible and this warning will be seen if trimming is enabled. https://aka.ms/dotnet-illink/nativehost [src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    src/libraries/System.Private.CoreLib/src/System/Resources/ResourceSet.cs(110,20): error IL2026: Using member 'System.Type.GetType(String, Boolean)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. The type might be removed. [src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    src/libraries/System.Private.CoreLib/src/System/Reflection/AssemblyName.cs(166,31): error IL2026: Using member 'System.Type.GetType(String, Boolean)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. The type might be removed. [src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    src/libraries/System.Private.CoreLib/src/System/Resources/ManifestBasedResourceGroveler.cs(238,36): error IL2026: Using member 'System.Resources.ManifestBasedResourceGroveler.InternalGetResourceSetFromSerializedData(Stream, String, String, ResourceManagerMediator)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. The CustomResourceTypesSupport feature switch has been enabled for this app which is being trimmed. Custom readers as well as custom objects on the resources file are not observable by the trimmer and so required assemblies, types and members may be removed. [src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    src/coreclr/System.Private.CoreLib/src/System/Diagnostics/StackFrameHelper.cs(104,41): error IL2026: Using member 'System.Type.GetType(String, Boolean)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. The type might be removed. [src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.cs(114,113): error IL2062: Value passed to parameter 'targetTypeHandle' of method 'System.Runtime.CompilerServices.RuntimeHelpers.GetSpanDataFrom(RuntimeFieldHandle, RuntimeTypeHandle, out Int32)' can not be statically determined and may not meet 'DynamicallyAccessedMembersAttribute' requirements. [src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    src/libraries/System.Private.CoreLib/src/System/Reflection/IntrospectionExtensions.cs(16,20): error IL2067: 'delegatingType' argument does not satisfy 'DynamicallyAccessedMemberTypes.All' in call to 'System.Reflection.TypeDelegator.TypeDelegator(Type)'. The parameter 'type' of method 'System.Reflection.IntrospectionExtensions.GetTypeInfo(Type)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to. [src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeConstructorInfo.CoreCLR.cs(200,17): error IL2026: Using member 'System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor(RuntimeTypeHandle)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Trimmer can't guarantee existence of class constructor. [src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    src/libraries/System.Private.CoreLib/src/System/SR.cs(81,21): error IL2026: Using member 'System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor(RuntimeTypeHandle)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Trimmer can't guarantee existence of class constructor. [src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    src/libraries/System.Private.CoreLib/src/System/SR.cs(82,21): error IL2026: Using member 'System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor(RuntimeTypeHandle)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Trimmer can't guarantee existence of class constructor. [src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    src/libraries/System.Private.CoreLib/src/System/SR.cs(83,21): error IL2026: Using member 'System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor(RuntimeTypeHandle)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Trimmer can't guarantee existence of class constructor. [src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    src/libraries/System.Private.CoreLib/src/System/SR.cs(84,21): error IL2026: Using member 'System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor(RuntimeTypeHandle)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Trimmer can't guarantee existence of class constructor. [src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/ModuleBuilder.cs(1109,33): error IL2026: Using member 'System.Reflection.Module.GetType(String, Boolean, Boolean)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Types might be removed. [src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/ILGenerator.cs(1131,32): error IL2026: Using member 'System.Type.GetType(String, Boolean)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. The type might be removed. [src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/ILGenerator.cs(1148,32): error IL2026: Using member 'System.Type.GetType(String, Boolean)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. The type might be removed. [src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/ILGenerator.cs(1175,32): error IL2026: Using member 'System.Type.GetType(String, Boolean)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. The type might be removed. [src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    src/coreclr/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs(1051,33): error IL2072: 'iList' argument does not satisfy 'DynamicallyAccessedMemberTypes.Interfaces' in call to 'System.RuntimeType.RuntimeTypeCache.MemberInfoCache<T>.AddSpecialInterface(ref ListBuilder<RuntimeType>, Filter, RuntimeType, Boolean)'. The return value of method 'System.Type.MakeGenericType(params Type[])' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to. [src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    src/coreclr/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs(1055,33): error IL2072: 'iList' argument does not satisfy 'DynamicallyAccessedMemberTypes.Interfaces' in call to 'System.RuntimeType.RuntimeTypeCache.MemberInfoCache<T>.AddSpecialInterface(ref ListBuilder<RuntimeType>, Filter, RuntimeType, Boolean)'. The return value of method 'System.Type.MakeGenericType(params Type[])' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to. [src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    src/coreclr/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs(1056,33): error IL2072: 'iList' argument does not satisfy 'DynamicallyAccessedMemberTypes.Interfaces' in call to 'System.RuntimeType.RuntimeTypeCache.MemberInfoCache<T>.AddSpecialInterface(ref ListBuilder<RuntimeType>, Filter, RuntimeType, Boolean)'. The return value of method 'System.Type.MakeGenericType(params Type[])' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to. [src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    src/coreclr/System.Private.CoreLib/src/System/StartupHookProvider.cs(104,17): error IL2026: Using member 'System.StartupHookProvider.CallStartupHook(StartupHookNameOrPath)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. The StartupHookSupport feature switch has been enabled for this app which is being trimmed. Startup hook code is not observable by the trimmer and so required assemblies, types and members may be removed. [src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    src/libraries/System.Private.CoreLib/src/System/Type.cs(174,55): error IL2085: 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.NonPublicConstructors' in call to 'System.Type.GetConstructors(BindingFlags)'. The implicit 'this' argument of method 'System.Type.GetConstructors()' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to. [src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    src/libraries/System.Private.CoreLib/src/System/Type.cs(186,51): error IL2085: 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.NonPublicEvents' in call to 'System.Type.GetEvents(BindingFlags)'. The implicit 'this' argument of method 'System.Type.GetEvents()' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to. [src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    src/libraries/System.Private.CoreLib/src/System/Type.cs(198,43): error IL2085: 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.NonPublicFields' in call to 'System.Type.GetFields(BindingFlags)'. The implicit 'this' argument of method 'System.Type.GetFields()' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to. [src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    src/libraries/System.Private.CoreLib/src/System/Type.cs(210,55): error IL2085: 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.NonPublicConstructors', 'DynamicallyAccessedMemberTypes.NonPublicMethods', 'DynamicallyAccessedMemberTypes.NonPublicFields', 'DynamicallyAccessedMemberTypes.NonPublicNestedTypes', 'DynamicallyAccessedMemberTypes.NonPublicProperties', 'DynamicallyAccessedMemberTypes.NonPublicEvents' in call to 'System.Type.GetMember(String, BindingFlags)'. The implicit 'this' argument of method 'System.Type.GetMember(String)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to. [src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    src/libraries/System.Private.CoreLib/src/System/Type.cs(225,45): error IL2085: 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.NonPublicConstructors', 'DynamicallyAccessedMemberTypes.NonPublicMethods', 'DynamicallyAccessedMemberTypes.NonPublicFields', 'DynamicallyAccessedMemberTypes.NonPublicNestedTypes', 'DynamicallyAccessedMemberTypes.NonPublicProperties', 'DynamicallyAccessedMemberTypes.NonPublicEvents' in call to 'System.Type.GetMembers(BindingFlags)'. The implicit 'this' argument of method 'System.Type.GetMembers()' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to. [src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    src/libraries/System.Private.CoreLib/src/System/Type.cs(337,45): error IL2085: 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Type.GetMethods(BindingFlags)'. The implicit 'this' argument of method 'System.Type.GetMethods()' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to. [src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    src/libraries/System.Private.CoreLib/src/System/Type.cs(343,52): error IL2085: 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.NonPublicNestedTypes' in call to 'System.Type.GetNestedType(String, BindingFlags)'. The implicit 'this' argument of method 'System.Type.GetNestedType(String)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to. [src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    src/libraries/System.Private.CoreLib/src/System/Type.cs(390,50): error IL2085: 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.NonPublicProperties' in call to 'System.Type.GetProperties(BindingFlags)'. The implicit 'this' argument of method 'System.Type.GetProperties()' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to. [src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    src/libraries/System.Private.CoreLib/src/System/Type.cs(349,43): error IL2085: 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.NonPublicNestedTypes' in call to 'System.Type.GetNestedTypes(BindingFlags)'. The implicit 'this' argument of method 'System.Type.GetNestedTypes()' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to. [src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    src/libraries/System.Private.CoreLib/src/System/AppDomain.cs(383,41): error IL2026: Using member 'System.Type.GetType(String, Boolean)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. The type might be removed. [src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    src/libraries/System.Private.CoreLib/src/System/AppDomain.cs(398,41): error IL2026: Using member 'System.Type.GetType(String, Boolean)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. The type might be removed. [src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    src/libraries/System.Private.CoreLib/src/System/Type.Helpers.cs(378,37): error IL2075: 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.Interfaces' in call to 'System.Type.GetInterfaces()'. The return value of method 'System.Type.BaseType.get' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to. [src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    

    Most of these are explained by lack of intrinsic support, as expected. One interesting case is the warning in Introspections.cs. This one was being produced for the method body of an intrinsic calling another intrinsic. It went away when we disabled the unimplemented intrinsics, but note that unlike the linker, the analyzer is currently analyzing the bodies of intrinsics. There were a few other warnings left after disabling warnings for unsupported intrinsics:

    src/libraries/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComponentActivator.cs(142,44): error IL2026: Using member 'Internal.Runtime.InteropServices.ComponentActivator.InternalGetFunctionPointer(AssemblyLoadContext, String, String, IntPtr)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Native hosting is not trim compatible and this warning will be seen if trimming is enabled. https://aka.ms/dotnet-illink/nativehost [src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    src/libraries/System.Private.CoreLib/src/System/Resources/ManifestBasedResourceGroveler.cs(238,36): error IL2026: Using member 'System.Resources.ManifestBasedResourceGroveler.InternalGetResourceSetFromSerializedData(Stream, String, String, ResourceManagerMediator)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. The CustomResourceTypesSupport feature switch has been enabled for this app which is being trimmed. Custom readers as well as custom objects on the resources file are not observable by the trimmer and so required assemblies, types and members may be removed. [src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    src/coreclr/System.Private.CoreLib/src/System/StartupHookProvider.cs(104,17): error IL2026: Using member 'System.StartupHookProvider.CallStartupHook(StartupHookNameOrPath)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. The StartupHookSupport feature switch has been enabled for this app which is being trimmed. Startup hook code is not observable by the trimmer and so required assemblies, types and members may be removed. [src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/ModuleBuilder.cs(1109,33): error IL2026: Using member 'System.Reflection.Module.GetType(String, Boolean, Boolean)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Types might be removed. [src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.cs(114,113): error IL2062: Value passed to parameter 'targetTypeHandle' of method 'System.Runtime.CompilerServices.RuntimeHelpers.GetSpanDataFrom(RuntimeFieldHandle, RuntimeTypeHandle, out Int32)' can not be statically determined and may not meet 'DynamicallyAccessedMembersAttribute' requirements. [src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    
    • The ComponentActivator.cs, ManifestBasedResourceGroveler.cs, and StartupHookProvider.cs are warnings which are silenced by XML suppressions.
    • The ModuleBuilder.cs looks like it's in unused code. The linker doesn't warn and there seem to be no references to the method so we can just delete it.
    • The RuntimeHelpers.cs one is a bug in the feature branch. The bug exists in shared code, and the linker is producing the warning too: [DAM analyzer] Don't produce dataflow warnings for annotations on invalid types #2598
  2. tlakollo commented on Feb 17, 2022

    @tlakollo
    Contributor

    I run again the analyzer in runtime, possibly in a different way than Sven and got very similar results

    src\libraries\System.Private.CoreLib\src\Internal\Runtime\InteropServices\ComponentActivator.cs(136,44): error IL2026: Using member 'Internal.Runtime.InteropServices.ComponentActivator.InternalGetFunctionPointer(AssemblyLoadContext, String, String, IntPtr)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Native hosting is not trim compatible and this warning will be seen if trimming is enabled. https://aka.ms/dotnet-illink/nativehost
    src\libraries\System.Private.CoreLib\src\System\Resources\ManifestBasedResourceGroveler.cs(238,36): error IL2026: Using member 'System.Resources.ManifestBasedResourceGroveler.InternalGetResourceSetFromSerializedData(Stream, String, String, ResourceManagerMediator)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. The CustomResourceTypesSupport feature switch has been enabled for this app which is being trimmed. Custom readers as well as custom objects on the resources file are not observable by the trimmer and so required assemblies, types and members may be removed.
    src\coreclr\System.Private.CoreLib\src\System\StartupHookProvider.cs(104,17): error IL2026: Using member 'System.StartupHookProvider.CallStartupHook(StartupHookNameOrPath)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. The StartupHookSupport feature switch has been enabled for this app which is being trimmed. Startup hook code is not observable by the trimmer and so required assemblies, types and members may be removed.
    src\coreclr\System.Private.CoreLib\src\System\Reflection\Emit\ModuleBuilder.cs(1109,33): error IL2026: Using member 'System.Reflection.Module.GetType(String, Boolean, Boolean)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Types might be removed.
    
    src\coreclr\System.Private.CoreLib\src\Internal\Runtime\InteropServices\InMemoryAssemblyLoader.cs(40,43): error IL2026: Using member 'Internal.Runtime.InteropServices.IsolatedComponentLoadContext.IsolatedComponentLoadContext(String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. The trimmer might remove assemblies that are loaded by this class. https://aka.ms/dotnet-illink/nativehost
    src\coreclr\System.Private.CoreLib\src\System\RuntimeType.CoreCLR.cs(2937,20): error IL2063: Value returned from method 'System.RuntimeType.GetInterface(String, Boolean)' can not be statically determined and may not meet 'DynamicallyAccessedMembersAttribute' requirements.
    

    We can see the following:

    • Warnings related to suppressions via xml prevail
    • RuntimeHelpers.cs warning disappeared after [DAM analyzer] Don't produce dataflow warnings for annotations on invalid types #2598 was merged
    • There is a new warning coming from InMemoryAssemblyLoader which is suppressed in runtime via xml (not sure why it was not presented before)
    • There is a new warning in RuntimeType.CoreCLR.cs related to GetInterface that I'm just not 100% sure if its a bug, I guess is in a weird spot because is the intrinsic method itself so not sure if it will be handled as an intrinsic or as a method with annotations, I'm guessing is the first one still I think is a very specific scenario @vitek-karas
  3. vitek-karas commented on Feb 17, 2022

    @vitek-karas
    Member

    The RuntimeType.GetInterface is a bug in the linker's data flow: #2624
    The analyzer is correct - there should be a warning reported here.
    I'm unsure about the fix - it's deep down in the MethodBodyScanner and could impact lot of cases.

  4. sbomer commented on Feb 22, 2022

    @sbomer
    MemberAuthor

    Closing since #2614 merged the feature branch.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions