Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,27 @@ jobs:
trx-file-path: '${{ runner.temp }}/*.trx'
output-directory: '${{ runner.temp }}/vsplaylists'

aot-test:
name: AOT publish test
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v6
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
global-json-file: global.json
- name: Install NativeAOT prerequisites
run: sudo apt-get install -y clang zlib1g-dev
- name: Publish AOT
run: dotnet publish IntelliTect.Multitool.AotTest/IntelliTect.Multitool.AotTest.csproj -r linux-x64 -c Release
- name: Run AOT binary
run: ./IntelliTect.Multitool.AotTest/bin/Release/net8.0/linux-x64/publish/IntelliTect.Multitool.AotTest

automerge:
needs: [build-and-test]
needs: [build-and-test, aot-test]
runs-on: ubuntu-latest

permissions:
Expand Down
13 changes: 13 additions & 0 deletions IntelliTect.Multitool.AotTest/IntelliTect.Multitool.AotTest.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
<PublishAot>true</PublishAot>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\IntelliTect.Multitool\IntelliTect.Multitool.csproj" />
</ItemGroup>
</Project>
27 changes: 27 additions & 0 deletions IntelliTect.Multitool.AotTest/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using IntelliTect.Multitool;
using IntelliTect.Multitool.Extensions;

// StringExtensions
bool slugOk = "Hello, World!".CreateUrlSlug() == "hello-world";
bool urlOk = "https://github.com/IntelliTect".ValidateUrlString();

// SystemLinqExtensions
string?[] items = ["a", null, "b", null, "c"];
bool filterOk = items.WhereNotNull().Count() == 3;

// ReleaseDateAttribute — returns null since no attribute on this assembly,
// but exercises the AOT-safe (statically-known type) GetCustomAttribute<T> code path
DateTime? releaseDate = ReleaseDateAttribute.GetReleaseDate();
bool attributeOk = releaseDate is null;

if (!slugOk || !urlOk || !filterOk || !attributeOk)
{
Console.Error.WriteLine("AOT test FAILED.");
return 1;
}

// RepositoryPaths is excluded: its static initializer reads a build-time temp file
// that doesn't exist at AOT runtime. The class is AOT-compatible (file I/O + LINQ only).

Console.WriteLine("AOT test passed.");
return 0;
1 change: 1 addition & 0 deletions IntelliTect.Multitool.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<File Path="global.json" />
<File Path="README.md" />
</Folder>
<Project Path="IntelliTect.Multitool.AotTest/IntelliTect.Multitool.AotTest.csproj" />
<Project Path="IntelliTect.Multitool.Tests/IntelliTect.Multitool.Tests.csproj" />
<Project Path="IntelliTect.Multitool/IntelliTect.Multitool.csproj" />
</Solution>
3 changes: 2 additions & 1 deletion IntelliTect.Multitool/IntelliTect.Multitool.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<TargetFrameworks>netstandard2.1;net8.0</TargetFrameworks>
<OutputType>Library</OutputType>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand All @@ -13,6 +13,7 @@
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<NeutralLanguage>en</NeutralLanguage>
<Version>1.0.1</Version>
<IsAotCompatible Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">true</IsAotCompatible>
Comment thread
BenjaminMichaelis marked this conversation as resolved.
</PropertyGroup>
<ItemGroup>
<CodeAnalysisDictionary Include="CustomDictionary.xml" />
Expand Down
3 changes: 1 addition & 2 deletions IntelliTect.Multitool/ReleaseDateAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ public class ReleaseDateAttribute(string utcDateString) : Attribute
/// <returns>The date time from the assembly attribute</returns>
public static DateTime? GetReleaseDate(Assembly? assembly = null)
{
object[]? attribute = (assembly ?? Assembly.GetEntryAssembly())?.GetCustomAttributes(typeof(ReleaseDateAttribute), false);
return attribute?.Length >= 1 ? ((ReleaseDateAttribute)attribute[0]).ReleaseDate : null;
return (assembly ?? Assembly.GetEntryAssembly())?.GetCustomAttribute<ReleaseDateAttribute>()?.ReleaseDate;
}

}
2 changes: 1 addition & 1 deletion IntelliTect.Multitool/RepositoryPaths.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static string GetDefaultRepoRoot()
}
}
// Search from the project directory if we are live unit testing or if the initial search failed.
if (BuildVariables.TryGetValue("ProjectPath", out string? projectPath))
if (BuildVariables.TryGetValue("ProjectPath", out string? projectPath) && !string.IsNullOrWhiteSpace(projectPath))
{
searchStartDirectory = new FileInfo(projectPath).Directory;
if (TrySearchForGitContainingDirectory(searchStartDirectory, out gitDirectory)
Expand Down
Loading