@
CI / build-test (push) Failing after 1m8s

Add MrGameEng.AI utility-AI module; format codebase with CSharpier

New MrGameEng.AI module (ResponseCurve, Consideration, UtilityAction,
UtilityAi selector, Blackboard) plus CSharpier formatting applied across
the whole engine. Documents the CSharpier convention in CLAUDE.md.
@
This commit is contained in:
Leonid Pershin
2026-06-12 07:19:10 +03:00
parent 4ae730cafa
commit fd6343bd09
96 changed files with 2066 additions and 589 deletions
@@ -23,7 +23,8 @@ public class AssetHandlesGeneratorTests
values.TryGetValue(key, out value!);
}
private sealed class FakeOptionsProvider(Dictionary<string, string> values) : AnalyzerConfigOptionsProvider
private sealed class FakeOptionsProvider(Dictionary<string, string> values)
: AnalyzerConfigOptionsProvider
{
public override AnalyzerConfigOptions GlobalOptions { get; } = new FakeOptions(values);
@@ -36,11 +37,18 @@ public class AssetHandlesGeneratorTests
{
var driver = CSharpGeneratorDriver.Create(
[new AssetHandlesGenerator().AsSourceGenerator()],
additionalTexts: Array.ConvertAll(files, f => (AdditionalText)new FakeAdditionalText(f)),
optionsProvider: new FakeOptionsProvider(options ?? new Dictionary<string, string>
{
["build_property.RootNamespace"] = "MyGame",
}));
additionalTexts: Array.ConvertAll(
files,
f => (AdditionalText)new FakeAdditionalText(f)
),
optionsProvider: new FakeOptionsProvider(
options
?? new Dictionary<string, string>
{
["build_property.RootNamespace"] = "MyGame",
}
)
);
var compilation = CSharpCompilation.Create("test");
var result = driver.RunGenerators(compilation).GetRunResult();
@@ -50,8 +58,7 @@ public class AssetHandlesGeneratorTests
[Fact]
public void GeneratesTypedHandles_ForKnownExtensions()
{
var source = RunGenerator(
[
var source = RunGenerator([
@"D:\game\Assets\Textures\player.png",
@"D:\game\Assets\Sounds\jump.wav",
@"D:\game\Assets\Fonts\main.ttf",
@@ -63,10 +70,12 @@ public class AssetHandlesGeneratorTests
Assert.Contains("public static class Textures", source);
Assert.Contains(
"AssetRef<global::Microsoft.Xna.Framework.Graphics.Texture2D> Player = new(\"Textures/player.png\")",
source);
source
);
Assert.Contains(
"AssetRef<global::Microsoft.Xna.Framework.Audio.SoundEffect> Jump = new(\"Sounds/jump.wav\")",
source);
source
);
Assert.Contains("AssetRef<global::FontStashSharp.FontSystem> Main", source);
Assert.Contains("AssetRef<global::MrGameEng.Core.MusicTrack> Theme", source);
}
@@ -74,8 +83,7 @@ public class AssetHandlesGeneratorTests
[Fact]
public void IgnoresUnknownExtensions_AndFilesOutsideAssets()
{
var source = RunGenerator(
[
var source = RunGenerator([
@"D:\game\Assets\readme.md",
@"D:\game\Other\image.png",
@"D:\game\Assets\valid.png",
@@ -89,8 +97,7 @@ public class AssetHandlesGeneratorTests
[Fact]
public void AtlasFiles_GetTextureAtlasHandles_AndPagesAreExcluded()
{
var source = RunGenerator(
[
var source = RunGenerator([
@"D:\game\Assets\Atlases\Things.Pawn.atlas",
@"D:\game\Assets\Atlases\Things.Pawn.atlas.0.png",
@"D:\game\Assets\Atlases\Things.Pawn.atlas.1.png",
@@ -98,7 +105,8 @@ public class AssetHandlesGeneratorTests
Assert.Contains(
"AssetRef<global::MrGameEng.Atlases.TextureAtlas> ThingsPawn = new(\"Atlases/Things.Pawn.atlas\")",
source);
source
);
Assert.DoesNotContain("Texture2D> ThingsPawn", source);
}
@@ -125,15 +133,33 @@ public class AssetHandlesGeneratorTests
var compilation = CSharpCompilation.Create(
"generated",
[CSharpSyntaxTree.ParseText(source, cancellationToken: TestContext.Current.CancellationToken),
CSharpSyntaxTree.ParseText(stubs, cancellationToken: TestContext.Current.CancellationToken)],
[MetadataReference.CreateFromFile(typeof(object).Assembly.Location),
MetadataReference.CreateFromFile(System.Runtime.Loader.AssemblyLoadContext.Default
.LoadFromAssemblyName(new System.Reflection.AssemblyName("System.Runtime")).Location)],
new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary));
[
CSharpSyntaxTree.ParseText(
source,
cancellationToken: TestContext.Current.CancellationToken
),
CSharpSyntaxTree.ParseText(
stubs,
cancellationToken: TestContext.Current.CancellationToken
),
],
[
MetadataReference.CreateFromFile(typeof(object).Assembly.Location),
MetadataReference.CreateFromFile(
System
.Runtime.Loader.AssemblyLoadContext.Default.LoadFromAssemblyName(
new System.Reflection.AssemblyName("System.Runtime")
)
.Location
),
],
new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary)
);
var errors = compilation.GetDiagnostics(TestContext.Current.CancellationToken)
.Where(d => d.Severity == DiagnosticSeverity.Error).ToList();
var errors = compilation
.GetDiagnostics(TestContext.Current.CancellationToken)
.Where(d => d.Severity == DiagnosticSeverity.Error)
.ToList();
Assert.Empty(errors);
}
@@ -162,7 +188,10 @@ public class AssetHandlesGeneratorTests
[InlineData(@"D:\game\Assets\icon.png", @"D:\game\", "icon.png")]
[InlineData(@"D:\game\Other\icon.png", @"D:\game", null)]
public void ToAssetPath_WithProjectDir_RootsAtProjectAssetsFolder(
string fullPath, string projectDir, string? expected)
string fullPath,
string projectDir,
string? expected
)
{
Assert.Equal(expected, AssetHandlesGenerator.ToAssetPath(fullPath, projectDir));
}
@@ -1,5 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<OutputType>Exe</OutputType>
@@ -16,5 +15,4 @@
<ItemGroup>
<ProjectReference Include="..\..\src\MrGameEng.Assets.Generator\MrGameEng.Assets.Generator.csproj" />
</ItemGroup>
</Project>