Skip to content

Conversation

@MichalStrehovsky
Copy link
Member

We're likely losing out on test coverage by not testing the recommended mainstream shipping configuration.

We're likely losing out on test coverage by not testing the recommended mainstream shipping configuration.
@MichalStrehovsky
Copy link
Member Author

/azp run runtime-nativeaot-outerloop

@github-actions github-actions bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Nov 17, 2025
@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@MichalStrehovsky
Copy link
Member Author

/azp run runtime-nativeaot-outerloop

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@MichalStrehovsky MichalStrehovsky added area-NativeAOT-coreclr and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Nov 17, 2025
MichalStrehovsky added a commit to MichalStrehovsky/runtime that referenced this pull request Nov 17, 2025
Fixes the build crash in dotnet#121697.

Since with TrimMode=partial, we consider all static fields targets of reflection, we cannot allow inlining their contents. With full trimming allowed, the optimization is unlocked and we hit an assert when trying to nullcheck a constant.
MichalStrehovsky added a commit that referenced this pull request Nov 17, 2025
Fixes the build crash in #121697.

Since with TrimMode=partial, we consider all static fields targets of
reflection, we cannot allow inlining their contents. With full trimming
allowed, the optimization is unlocked and we hit an assert when trying
to nullcheck a constant.
@MichalStrehovsky
Copy link
Member Author

/azp run runtime-nativeaot-outerloop

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@MichalStrehovsky
Copy link
Member Author

@copilot there are some tests that are failing due to trimming under src/tests/Loader/classloader/generics/Variance/IL. The failure is caused by removal of default constructor.

The failure in each of the tests is caused by:

	private static void UnboxUToTInternal<T,U>()
	{
		T t = (T) Activator.CreateInstance(typeof(U));
	}

This method is replicated in many tests.

To fix the failure the methods private static void UnboxUToTInternal<T,U>() need to be annotated like this: private static void UnboxUToTInternal<T, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] U>(). The namespace of the attribute is System.Diagnostics.CodeAnalysis.

The attribute may need to be propagated to each of the callsites too. For example:

	private static void CaseClassUToTWrapper<T,U>()
	{
		UnboxUToTInternal<T,U>();
	}

needs to be annotated as private static void CaseClassUToTWrapper<T, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] U>(). The annotation needs to be applied transitively until the context is no longer generic. Make this change to all tests under src/tests/Loader/classloader/generics/Variance/IL.

Copy link
Contributor

Copilot AI commented Nov 18, 2025

@MichalStrehovsky I've opened a new pull request, #121731, to work on those changes. Once the pull request is ready, I'll request review from you.

@MichalStrehovsky
Copy link
Member Author

@copilot for C# source files under src/tests/Loader/classloader/generics/Variance/IL, find the following method in each of the files: private static void UnboxUToTInternal<T,U>(). Add an attribute like this: private static void UnboxUToTInternal<T, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] U>(). The namespace of the attribute is System.Diagnostics.CodeAnalysis.

Copy link
Contributor

Copilot AI commented Nov 18, 2025

@MichalStrehovsky I've opened a new pull request, #121734, to work on those changes. Once the pull request is ready, I'll request review from you.

MichalStrehovsky added a commit that referenced this pull request Nov 19, 2025
* `dynamic` keyword is unsupported with AOT
* So are ALCs
* `GetInterfaceMap` API has known issues (the test actually passes right
now, but will fail with #121697 so just disabling now)
@MichalStrehovsky
Copy link
Member Author

@copilot for C# source files under src/tests/Loader/classloader/generics/Variance/IL, find the following method in each of the files: public static bool UIsInstT<T,U>(bool expected). Add an attribute like this: public static bool UIsInstT<T, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] U>(bool expected). The namespace of the attribute is System.Diagnostics.CodeAnalysis.

Copy link
Contributor

Copilot AI commented Nov 20, 2025

@MichalStrehovsky I've opened a new pull request, #121833, to work on those changes. Once the pull request is ready, I'll request review from you.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants