|
2 | 2 | <!-- |
3 | 3 | AOT/trim WARNING fixture. |
4 | 4 |
|
5 | | - This project's job is to FAIL TO BUILD. It calls the Autofac APIs that are |
6 | | - annotated [RequiresDynamicCode] / [RequiresUnreferencedCode], with |
7 | | - IsAotCompatible=true (which turns on the trim/AOT analyzers) and |
8 | | - TreatWarningsAsErrors=true, so the analyzer diagnostics become build errors. |
| 5 | + This project is EXPECTED TO BUILD SUCCESSFULLY and, in doing so, emit the |
| 6 | + trim/AOT analyzer warnings (IL2026 / IL3050) for the Autofac APIs that are |
| 7 | + annotated [RequiresUnreferencedCode] / [RequiresDynamicCode]. Setting |
| 8 | + IsAotCompatible=true turns on those analyzers, and TreatWarningsAsErrors is left |
| 9 | + OFF so the warnings stay warnings (and the build still succeeds). |
9 | 10 |
|
10 | | - The 'VerifyAotWarnings' target in default.proj builds this project EXPECTING |
11 | | - failure and asserts that the expected IL2026/IL3050 codes appear. That guards |
| 11 | + The 'VerifyAotWarnings' target in default.proj builds this project and asserts |
| 12 | + the expected IL codes appear in the (successful) build output. That guards |
12 | 13 | against silently LOSING a [Requires*] attribute in a future refactor: if an |
13 | | - annotation is dropped, the corresponding warning stops firing, this project |
14 | | - starts building successfully, and the verification target fails. |
| 14 | + annotation is dropped, the corresponding warning stops firing and the target |
| 15 | + fails because an expected code is missing. |
15 | 16 |
|
16 | 17 | Unlike the runtime smoke test (Autofac.Test.Aot) this needs no native toolchain - |
17 | 18 | plain 'dotnet build' surfaces the analyzer diagnostics - so it runs in normal CI. |
18 | 19 |
|
19 | | - It is intentionally NOT part of Autofac.sln so the normal build does not try to |
20 | | - compile a project that is designed not to compile. |
| 20 | + It is intentionally NOT part of Autofac.sln; it exists only to be built by the |
| 21 | + verify target. |
21 | 22 | --> |
22 | 23 | <PropertyGroup> |
23 | 24 | <OutputType>Exe</OutputType> |
|
26 | 27 | <ImplicitUsings>enable</ImplicitUsings> |
27 | 28 | <IsPackable>false</IsPackable> |
28 | 29 | <IsTestProject>false</IsTestProject> |
| 30 | + <!-- Sign to match the rest of the repo's assemblies (and the sibling AOT test project). --> |
| 31 | + <AssemblyOriginatorKeyFile>../../Autofac.snk</AssemblyOriginatorKeyFile> |
| 32 | + <SignAssembly>true</SignAssembly> |
29 | 33 | <!-- Turn on the trim/AOT analyzers so the [Requires*] diagnostics are emitted. --> |
30 | 34 | <IsAotCompatible>true</IsAotCompatible> |
31 | 35 | <TrimmerSingleWarn>false</TrimmerSingleWarn> |
32 | 36 | <!-- |
33 | | - This project is verified by building it and asserting it fails. Do not let a |
34 | | - stray analyzer/style rule turn into an error that masks the IL diagnostics, and |
35 | | - do not treat the deliberate IL warnings as errors here - the verify target reads |
36 | | - them from the (failed-by-design) build output instead. |
| 37 | + Keep TreatWarningsAsErrors OFF: this project is supposed to build successfully |
| 38 | + WITH the trim/AOT warnings present, and the verify target reads the IL codes |
| 39 | + from that successful build output. Treating them as errors would fail the build |
| 40 | + and there would be no output to inspect. |
37 | 41 | --> |
38 | 42 | <TreatWarningsAsErrors>false</TreatWarningsAsErrors> |
39 | 43 | <RunAnalyzers>true</RunAnalyzers> |
|
0 commit comments