Commit fdac6a8
authored
Add AOT compatibility for net8.0 TFM (#197)
## Summary
Makes IntelliTect.Multitool AOT-compatible so that consumers on .NET 8+
can publish with NativeAOT or trimming without warnings originating from
this library. Older consumers on `netstandard2.1` are unaffected.
## Changes
### Multi-target `netstandard2.1;net8.0`
NuGet automatically selects the best matching TFM — `net8.0+` consumers
get the AOT-annotated assembly; older consumers fall back to
`netstandard2.1`.
### `IsAotCompatible` for net7.0+ TFMs
```xml
<IsAotCompatible Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0'))">true</IsAotCompatible>
```
Enables the AOT, trim, and single-file analyzers for `net8.0` (and any
future TFMs added). Uses `IsTargetFrameworkCompatible` instead of a
hardcoded equality check so it automatically applies to `net10.0`, etc.
### Fix non-generic reflection in `ReleaseDateAttribute.GetReleaseDate`
```csharp
// Before — non-generic, causes IL2070 trim warning
object[]? attribute = assembly?.GetCustomAttributes(typeof(ReleaseDateAttribute), false);
// After — generic, trimmer can statically resolve the type
return assembly?.GetCustomAttribute<ReleaseDateAttribute>()?.ReleaseDate;
```
### Null guard in `RepositoryPaths.GetDefaultRepoRoot`
Added `&& projectPath is not null` to guard against the dictionary
returning a null value — required for correctness under `net8.0`'s
stricter nullable annotations with `TreatWarningsAsErrors`.
## Verification
- ✅ Build passes with zero warnings across `netstandard2.1`, `net8.0`,
and `net10.0` (test project)
- ✅ `TreatWarningsAsErrors=true` — all AOT/trim analyzers ran clean
- ✅ 30/32 tests pass; 2 pre-existing failures are unrelated worktree
path tests1 parent 0afc7dd commit fdac6a8
7 files changed
Lines changed: 65 additions & 5 deletions
File tree
- .github/workflows
- IntelliTect.Multitool.AotTest
- IntelliTect.Multitool
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
40 | 59 | | |
41 | | - | |
| 60 | + | |
42 | 61 | | |
43 | 62 | | |
44 | 63 | | |
| |||
Lines changed: 13 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | | - | |
| 25 | + | |
27 | 26 | | |
28 | 27 | | |
29 | 28 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| |||
0 commit comments