Skip to content

Conversation

@buyaa-n
Copy link
Contributor

@buyaa-n buyaa-n commented Nov 20, 2023

Fix Trim analysis warning IL2075 that causing runtime to SDK dependency flow failure:

Microsoft.NET.Publish.Tests.GivenThatWeWantToRunILLink.ILLink_verify_analysis_warnings_framework_assemblies(targetFramework: "net9.0") [FAIL]
      Target framework from test: net9.0
      Runtime identifier: win-x64
      Runtime Assembly Informational Version: 9.0.0-alpha.1.23569.1+83f116627e2548c7a55b3701bd5448570b84a784
      The execution of a hello world app generated a diff in the number of warnings the app produces
      
      Test output contained the following extra linker warnings:
      + ILLink : Trim analysis warning IL2075: System.Reflection.Emit.TypeBuilderImpl.DefineDefaultConstructorInternal(MethodAttributes): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors', 'DynamicallyAccessedMemberTypes.NonPublicConstructors' in call to 'System.Type.GetConstructor(BindingFlags, Binder, Type[], ParameterModifier[])'. The return value of method 'System.Type.GetGenericTypeDefinition()' 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. [C:\h\w\AEB609AF\t\dotnetSdkTests\zr3hzldq.dko\ILLink_verify---A58CFA90\AnalysisWarningsOnHelloWorldApp\AnalysisWarningsOnHelloWorldApp.csproj]
      
Running C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\msbuild.exe /t:Publish C:\h\w\AEB609AF\t\dotnetSdkTests\zr3hzldq.dko\ILLink_roots_---79577E81\HelloWorld\HelloWorld.csproj /restore /p:RuntimeIdentifier=win-x64 /p:PublishTrimmed=true
> C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\msbuild.exe /t:Publish C:\h\w\AEB609AF\t\dotnetSdkTests\zr3hzldq.dko\ILLink_roots_---79577E81\HelloWorld\HelloWorld.csproj /restore /p:RuntimeIdentifier=win-x64 /p:PublishTrimmed=true
      Stack Trace:
        /_/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToRunILLink.cs(984,0): at Microsoft.NET.Publish.Tests.GivenThatWeWantToRunILLink.ValidateWarningsOnHelloWorldApp(PublishCommand publishCommand, CommandResult result, List`1 expectedWarnings, String targetFramework, String rid, Boolean useRegex)
        /_/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToRunILLink.cs(896,0): at Microsoft.NET.Publish.Tests.GivenThatWeWantToRunILLink.ILLink_verify_analysis_warnings_framework_assemblies(String targetFramework)
           at InvokeStub_GivenThatWeWantToRunILLink.ILLink_verify_analysis_warnings_framework_assemblies(Object, Span`1)
           at System.Reflection.MethodBaseInvoker.InvokeWithOneArg(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)

The failure was not happening during local and runtime CI build

@ghost ghost assigned buyaa-n Nov 20, 2023
@ghost
Copy link

ghost commented Nov 20, 2023

Tagging subscribers to this area: @dotnet/area-system-reflection-emit
See info in area-owners.md if you want to be subscribed.

Issue Details

Fix Trim analysis warning IL2075 that causing runtime to SDK dependency flow failure:

Microsoft.NET.Publish.Tests.GivenThatWeWantToRunILLink.ILLink_verify_analysis_warnings_framework_assemblies(targetFramework: "net9.0") [FAIL]
      Target framework from test: net9.0
      Runtime identifier: win-x64
      Runtime Assembly Informational Version: 9.0.0-alpha.1.23569.1+83f116627e2548c7a55b3701bd5448570b84a784
      The execution of a hello world app generated a diff in the number of warnings the app produces
      
      Test output contained the following extra linker warnings:
      + ILLink : Trim analysis warning IL2075: System.Reflection.Emit.TypeBuilderImpl.DefineDefaultConstructorInternal(MethodAttributes): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors', 'DynamicallyAccessedMemberTypes.NonPublicConstructors' in call to 'System.Type.GetConstructor(BindingFlags, Binder, Type[], ParameterModifier[])'. The return value of method 'System.Type.GetGenericTypeDefinition()' 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. [C:\h\w\AEB609AF\t\dotnetSdkTests\zr3hzldq.dko\ILLink_verify---A58CFA90\AnalysisWarningsOnHelloWorldApp\AnalysisWarningsOnHelloWorldApp.csproj]
      
Running C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\msbuild.exe /t:Publish C:\h\w\AEB609AF\t\dotnetSdkTests\zr3hzldq.dko\ILLink_roots_---79577E81\HelloWorld\HelloWorld.csproj /restore /p:RuntimeIdentifier=win-x64 /p:PublishTrimmed=true
> C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\msbuild.exe /t:Publish C:\h\w\AEB609AF\t\dotnetSdkTests\zr3hzldq.dko\ILLink_roots_---79577E81\HelloWorld\HelloWorld.csproj /restore /p:RuntimeIdentifier=win-x64 /p:PublishTrimmed=true
      Stack Trace:
        /_/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToRunILLink.cs(984,0): at Microsoft.NET.Publish.Tests.GivenThatWeWantToRunILLink.ValidateWarningsOnHelloWorldApp(PublishCommand publishCommand, CommandResult result, List`1 expectedWarnings, String targetFramework, String rid, Boolean useRegex)
        /_/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToRunILLink.cs(896,0): at Microsoft.NET.Publish.Tests.GivenThatWeWantToRunILLink.ILLink_verify_analysis_warnings_framework_assemblies(String targetFramework)
           at InvokeStub_GivenThatWeWantToRunILLink.ILLink_verify_analysis_warnings_framework_assemblies(Object, Span`1)
           at System.Reflection.MethodBaseInvoker.InvokeWithOneArg(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)

The failure was not happening during local and runtime CI build

Author: buyaa-n
Assignees: buyaa-n
Labels:

area-System.Reflection.Emit

Milestone: -

@buyaa-n buyaa-n merged commit 6036eaf into dotnet:main Nov 20, 2023
@buyaa-n buyaa-n deleted the suppress-warning branch November 20, 2023 05:18
@github-actions github-actions bot locked and limited conversation to collaborators Dec 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants