diff options
author | Tlakaelel Axayakatl Ceja <tlakaelel.ceja@microsoft.com> | 2021-02-05 01:07:02 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-05 01:07:02 +0300 |
commit | 9b71e7b1e0827aee8fb43baa1e599e35cdeeed03 (patch) | |
tree | f55cf2bcad5696464df27d3fe69d8df3c8bc17c7 /docs | |
parent | 92f927ebcbd06da82f1987879c180253e8e81642 (diff) |
RequiresAssemblyFilesAttribute resource manager changes (#1790)
* Change resource file to have a default message and accept arguments
* Add test for RequiresAssemblyFilesAttribute with Url named argument only
* Add IL3XXX warning codes to the master error code registry
* Throw whenever a named argument is passed in ExpectedWarning
Diffstat (limited to 'docs')
-rw-r--r-- | docs/error-codes.md | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/docs/error-codes.md b/docs/error-codes.md index d2081505f..3a66bde74 100644 --- a/docs/error-codes.md +++ b/docs/error-codes.md @@ -1508,4 +1508,50 @@ This is technically possible if a custom assembly defines `DynamicDependencyAttr <type fullname="MyType" /> </assembly> </linker> + ``` + +## Single-File Warning Codes + +#### `IL3000`: 'member' always returns an empty string for assemblies embedded in a single-file app. If the path to the app directory is needed, consider calling 'System.AppContext.BaseDirectory' + +- Calls to 'System.Reflection.Assembly.Location', 'System.Reflection.AssemblyName.CodeBase' and 'System.Reflection.AssemblyName.EscapedCodeBase' return an empty string for assemblies embedded in a single-file app. If the path to the app directory is needed, consider calling 'System.AppContext.BaseDirectory' + + ``` C# + void TestMethod() + { + var a = Assembly.GetExecutingAssembly(); + // IL3000: 'System.Reflection.Assembly.Location' always returns an empty string for assemblies embedded in a single-file app. If the path to the app directory is needed, consider calling 'System.AppContext.BaseDirectory'. + _ = a.Location; + } + ``` + +#### `IL3001`: Assemblies embedded in a single-file app cannot have additional files in the manifest. + +- Calls to 'Assembly.GetFile(s)' methods for assemblies embedded inside the single-file bundle always throws an exception. Consider using embedded resources and the 'Assembly.GetManifestResourceStream' method. + + ``` C# + void TestMethod() + { + var a = Assembly.GetExecutingAssembly(); + // IL3001: Assemblies embedded in a single-file app cannot have additional files in the manifest. + _ = a.GetFiles(); + } + ``` + +#### `IL3002`: Using member 'member' which has 'RequiresAssemblyFilesAttribute' can break functionality when embedded in a single-file app. [message]. [url] + +- The linker found a call to a member annotated with 'RequiresAssemblyFilesAttribute' which can break functionality of a single-file application. + + ```C# + [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(); + } ```
\ No newline at end of file |