-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Document IL2125 and IL3058 transitive reference compatibility warnings #50266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
3ec08d1
07c49f1
5a84e99
d7b36c9
af0c6e5
b7f9860
dd89415
ddfdc9a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,60 @@ | ||||||||||||
| --- | ||||||||||||
| title: "IL3058: Referenced assembly is not annotated for AOT compatibility" | ||||||||||||
| description: "Learn about warning IL3058: Referenced assembly is not annotated for AOT compatibility" | ||||||||||||
| ms.date: 12/02/2024 | ||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
| ai-usage: ai-assisted | ||||||||||||
| f1_keywords: | ||||||||||||
| - "IL3058" | ||||||||||||
| --- | ||||||||||||
| # IL3058: Referenced assembly is not annotated for AOT compatibility | ||||||||||||
|
|
||||||||||||
| ## Cause | ||||||||||||
|
|
||||||||||||
| A project has `<VerifyReferenceAotCompatibility>true</VerifyReferenceAotCompatibility>` set, and one or more referenced assemblies don't have the `IsAotCompatible` assembly metadata attribute set to `true`. | ||||||||||||
|
|
||||||||||||
| ## Rule description | ||||||||||||
|
|
||||||||||||
| When you enable AOT analysis with `<EnableAotAnalyzer>true</EnableAotAnalyzer>` or mark your project as AOT-compatible with `<IsAotCompatible>true</IsAotCompatible>`, you can optionally enable verification that all referenced assemblies are also annotated for AOT compatibility. This helps ensure that all dependencies in your project are annotated for AOT compatibility. | ||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: also when |
||||||||||||
|
|
||||||||||||
| To enable this verification, set the `VerifyReferenceAotCompatibility` property to `true` in your project file: | ||||||||||||
|
|
||||||||||||
| ```xml | ||||||||||||
| <PropertyGroup> | ||||||||||||
| <EnableAotAnalyzer>true</EnableAotAnalyzer> | ||||||||||||
| <VerifyReferenceAotCompatibility>true</VerifyReferenceAotCompatibility> | ||||||||||||
| </PropertyGroup> | ||||||||||||
| ``` | ||||||||||||
|
|
||||||||||||
| When this property is enabled, the analyzer checks that all referenced assemblies have been built with `<IsAotCompatible>true</IsAotCompatible>`, which adds the assembly-level attribute `[assembly: AssemblyMetadata("IsAotCompatible", "True")]` to the assembly. | ||||||||||||
|
|
||||||||||||
| ## Example | ||||||||||||
|
|
||||||||||||
| ```csharp | ||||||||||||
| // Assembly reference: MyLibrary.dll (built without <IsAotCompatible>true</IsAotCompatible>) | ||||||||||||
| public class Program | ||||||||||||
| { | ||||||||||||
| public static void Main() | ||||||||||||
| { | ||||||||||||
| var obj = new MyLibrary.SomeClass(); | ||||||||||||
| } | ||||||||||||
| } | ||||||||||||
| ``` | ||||||||||||
|
|
||||||||||||
| ``` | ||||||||||||
| warning IL3058: Referenced assembly 'MyLibrary' is not built with `<IsAotCompatible>true</IsAotCompatible>` and may not be compatible with AOT. | ||||||||||||
| ``` | ||||||||||||
|
|
||||||||||||
| ## How to fix violations | ||||||||||||
|
|
||||||||||||
| You have several options to fix this warning: | ||||||||||||
|
|
||||||||||||
| 1. **Update the referenced library** to be built with `<IsAotCompatible>true</IsAotCompatible>`. This is the preferred approach if you control the library source code. The `IsAotCompatible` property marks the assembly as compatible with Native AOT and enables AOT-specific analysis. | ||||||||||||
|
|
||||||||||||
| 2. **Disable the verification** by setting `<VerifyReferenceAotCompatibility>false</VerifyReferenceAotCompatibility>` in your project file if you're confident that the library works correctly with Native AOT even without the attribute. | ||||||||||||
|
Comment on lines
+52
to
+54
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
|
|
||||||||||||
| ## See also | ||||||||||||
|
|
||||||||||||
| - [Native AOT deployment](../index.md) | ||||||||||||
| - [Introduction to AOT warnings](../fixing-warnings.md) | ||||||||||||
| - [Prepare .NET libraries for trimming](../../trimming/prepare-libraries-for-trimming.md) | ||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,60 @@ | ||||||||||||
| --- | ||||||||||||
| title: "IL2125: Referenced assembly is not annotated for trim compatibility" | ||||||||||||
| description: "Learn about trim warning IL2125: Referenced assembly is not annotated for trim compatibility" | ||||||||||||
| ms.date: 12/02/2024 | ||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
| ai-usage: ai-assisted | ||||||||||||
| f1_keywords: | ||||||||||||
| - "IL2125" | ||||||||||||
| --- | ||||||||||||
| # IL2125: Referenced assembly is not annotated for trim compatibility | ||||||||||||
|
|
||||||||||||
| ## Cause | ||||||||||||
|
|
||||||||||||
| A project has `<VerifyReferenceTrimCompatibility>true</VerifyReferenceTrimCompatibility>` set, and one or more referenced assemblies don't have the `IsTrimmable` assembly metadata attribute set to `true`. | ||||||||||||
|
|
||||||||||||
| ## Rule description | ||||||||||||
|
|
||||||||||||
| When you enable trim analysis with `<EnableTrimAnalyzer>true</EnableTrimAnalyzer>` or mark your project as trimmable with `<IsTrimmable>true</IsTrimmable>`, you can optionally enable verification that all referenced assemblies are also annotated for trim compatibility. This helps ensure that all dependencies in your project are annotated for trim compatibility. | ||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: here too, trim analysis is enabled with PublishTrimmed=true |
||||||||||||
|
|
||||||||||||
| To enable this verification, set the `VerifyReferenceTrimCompatibility` property to `true` in your project file: | ||||||||||||
|
|
||||||||||||
| ```xml | ||||||||||||
| <PropertyGroup> | ||||||||||||
| <EnableTrimAnalyzer>true</EnableTrimAnalyzer> | ||||||||||||
| <VerifyReferenceTrimCompatibility>true</VerifyReferenceTrimCompatibility> | ||||||||||||
| </PropertyGroup> | ||||||||||||
| ``` | ||||||||||||
|
|
||||||||||||
| When this property is enabled, the analyzer checks that all referenced assemblies have been built with `<IsTrimmable>true</IsTrimmable>`, which adds the assembly-level attribute `[assembly: AssemblyMetadata("IsTrimmable", "True")]` to the assembly. | ||||||||||||
|
|
||||||||||||
| ## Example | ||||||||||||
|
|
||||||||||||
| ```csharp | ||||||||||||
| // Assembly reference: MyLibrary.dll (built without <IsTrimmable>true</IsTrimmable>) | ||||||||||||
| public class Program | ||||||||||||
| { | ||||||||||||
| public static void Main() | ||||||||||||
| { | ||||||||||||
| var obj = new MyLibrary.SomeClass(); | ||||||||||||
| } | ||||||||||||
| } | ||||||||||||
| ``` | ||||||||||||
|
|
||||||||||||
| ``` | ||||||||||||
| warning IL2125: Referenced assembly 'MyLibrary' is not built with `<IsTrimmable>true</IsTrimmable>` and may not be compatible with trimming. | ||||||||||||
| ``` | ||||||||||||
|
|
||||||||||||
| ## How to fix violations | ||||||||||||
|
|
||||||||||||
| You have several options to fix this warning: | ||||||||||||
|
|
||||||||||||
| 1. **Update the referenced library** to be built with `<IsTrimmable>true</IsTrimmable>`. This is the preferred approach if you control the library source code. See [Prepare .NET libraries for trimming](../prepare-libraries-for-trimming.md) for guidance on making libraries trim-compatible. | ||||||||||||
|
|
||||||||||||
| 2. **Disable the verification** by setting `<VerifyReferenceTrimCompatibility>false</VerifyReferenceTrimCompatibility>` in your project file if you're confident that the library works correctly with trimming even without the attribute. | ||||||||||||
|
Comment on lines
+52
to
+54
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
|
|
||||||||||||
| ## See also | ||||||||||||
|
|
||||||||||||
| - [Prepare .NET libraries for trimming](../prepare-libraries-for-trimming.md) | ||||||||||||
| - [Introduction to trim warnings](../fixing-warnings.md) | ||||||||||||
| - [Trim self-contained deployments and executables](../trim-self-contained.md) | ||||||||||||
Uh oh!
There was an error while loading. Please reload this page.