Skip to content

Conversation

jtschuster
Copy link
Member

Updates the docs related to the trimmer to include info about warning IL3003

@gewarren
Copy link
Contributor

Please also add an entry to https://github.com/dotnet/docs/blob/main/docs/fundamentals/toc.yml.

}
void TestMethod()
{
// IL3002: Using member 'MethodWithAssemblyFilesUsage' which has 'RequiresAssemblyFilesAttribute'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation looks off

Comment on lines +13 to +17
| | Value |
|-------------------------------------|--------------------------------------|
| **Rule ID** | IL3003 |
| **Category** | [SingleFile](singlefile-warnings.md) |
| **Fix is breaking or non-breaking** | Non-breaking |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This table looks different from other docs, I think we should be consistent


## Cause

When publishing as a single file (for example, by setting the PublishSingleFile property in a project to true), interface implementations or derived classes with members that don't have matching annotations of `[RequiresAssemblyFiles]` can lead to calling an unsafe member with the attribute. There are four possible scenarios where the warning can be generated:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, please avoid "Safe"/"Unsafe" wording - it feels too much like security related. For trimming we've been trying to use "trim compatible", we can do the same for single-file.


When publishing as a single file (for example, by setting the PublishSingleFile property in a project to true), calling the `Assembly.GetFile(s)` methods for
assemblies embedded inside the single-file bundle always throws an exception.
assemblies embedded inside the single-file bundle always throws an exception, as these methods are not trim compatible.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the confusion, although Vitek mentioned that the wording safe/unsafe is something we want to avoid, the term trim compatible does not apply for single file, since trimming is an independent process that might or might not be executed for single-file apps. The term to document would be 'single-file compatible'

## Cause

When publishing an app as a single file (for example, by setting the `PublishSingleFile` property in a project to `true`), calling members annotated with the `RequiresAssemblyFilesAttribute` attribute might be unsafe. These calls can be unsafe because members annotated with this attribute require assembly files to be on disk, and the assemblies embedded in a single-file app are memory loaded.
When publishing an app as a single file (for example, by setting the `PublishSingleFile` property in a project to `true`), calling members annotated with the `RequiresAssemblyFilesAttribute` attribute is not trim compatible. These calls is not trim compatible because members annotated with this attribute require assembly files to be on disk, and the assemblies embedded in a single-file app are memory loaded.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still talks about "Trim compatible" - but it's about single-file.

@jtschuster jtschuster marked this pull request as ready for review January 7, 2022 17:01
@jtschuster jtschuster requested review from a team and gewarren as code owners January 7, 2022 17:01
@gewarren gewarren merged commit 8b9a646 into dotnet:main Jan 11, 2022
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.

5 participants