Muokkaa

Jaa


IL3002: Avoid calling members annotated with 'RequiresAssemblyFilesAttribute' when publishing as a single file.

Value
Rule ID IL3002
Category SingleFile
Fix is breaking or nonbreaking Nonbreaking

Cause

When you publish an app as a single file (for example, by setting the PublishSingleFile property to true in a project), calling members annotated with the RequiresAssemblyFilesAttribute attribute is not single-file compatible. These calls aren't 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.

Example:

[RequiresAssemblyFiles(Message="Use 'MethodFriendlyToSingleFile' instead", Url="http://help/assemblyfiles")]
void MethodWithAssemblyFilesUsage()
{
}
void TestMethod()
{
    // IL3002: Using member 'MethodWithAssemblyFilesUsage' which has 'RequiresAssemblyFilesAttribute'
    // can break functionality when embedded in a single-file app. Use 'MethodFriendlyToSingleFile' instead. http://help/assemblyfiles
    MethodWithAssemblyFilesUsage();
}

How to fix violations

Members annotated with the 'RequiresAssemblyFilesAttribute' attribute have a message intended to give useful information to users who are publishing as a single file. Consider adapting existing code to the attribute's message or removing the violating call.

When to suppress warnings

It's appropriate to suppress the warning when the existing code has been adapted to the recommendation outlined in the 'RequiresAssemblyFilesAttribute' attribute's message.