Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 20, 2025

Fixes Issue

main PR

Description

Added [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] attribute to the U type parameter in the UIsInstT<T,U> method across six variance test files (IsInst001.cs through IsInst006.cs) under src/tests/Loader/classloader/generics/Variance/IL.

This annotation is required because the method calls Activator.CreateInstance(typeof(U)), which needs the type to have a public parameterless constructor. Without this attribute, the trimmer removes the constructor when building with TrimMode=full, causing test failures.

Also added the required using System.Diagnostics.CodeAnalysis; namespace to all six files.

Customer Impact

Ensures proper test coverage for trimming scenarios. Without these attributes, variance tests would fail when built with TrimMode=full, reducing our confidence in the trimming behavior of variance-related functionality.

Regression

Not applicable - this is new work for trimming compatibility to enable building the test tree with TrimMode=full.

Testing

  • Changes follow the same pattern as previous work on UnboxUToTInternal methods
  • Modified files compile successfully
  • No security vulnerabilities detected by CodeQL

Risk

Low - changes only add trimming annotations to test code without altering test logic or functionality.

Package authoring no longer needed in .NET 9

IMPORTANT: Starting with .NET 9, you no longer need to edit a NuGet package's csproj to enable building and bump the version.
Keep in mind that we still need package authoring in .NET 8 and older versions.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Build the test tree with TrimMode=full Clarify incomplete instruction for UIsInstT method attribute addition Nov 20, 2025
Copilot finished work on behalf of MichalStrehovsky November 20, 2025 07:27
@MichalStrehovsky
Copy link
Member

MichalStrehovsky commented Nov 20, 2025

@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.

1 similar comment
@MichalStrehovsky
Copy link
Member

@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.

Co-authored-by: MichalStrehovsky <13110571+MichalStrehovsky@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Nov 20, 2025

@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 ...

Completed - see commit bfd0090.

@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 ...

Added [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] attribute to the U type parameter in the UIsInstT<T,U> method across all six IsInst test files (IsInst001-006.cs). Also added the required using System.Diagnostics.CodeAnalysis; namespace. Changes committed in bfd0090.

Copilot AI changed the title Clarify incomplete instruction for UIsInstT method attribute addition Add DynamicallyAccessedMembers attributes to UIsInstT methods in variance tests Nov 20, 2025
Copilot finished work on behalf of MichalStrehovsky November 20, 2025 08:15
@MichalStrehovsky MichalStrehovsky marked this pull request as ready for review November 20, 2025 08:18
@MichalStrehovsky MichalStrehovsky merged commit 67c6b16 into MichalStrehovsky-patch-1 Nov 20, 2025
11 of 13 checks passed
@MichalStrehovsky MichalStrehovsky deleted the copilot/sub-pr-121697 branch November 20, 2025 08:18
MichalStrehovsky pushed a commit to MichalStrehovsky/runtime that referenced this pull request Nov 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants