Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
7938a0c
Update ClangSharp.PInvokeGenerator
Exanite Apr 14, 2026
78b8ec4
Update comment on ModifyAllReferencesAsync in TransformHandles
Exanite Apr 14, 2026
a11ef49
Format files using CSharpier
Exanite Apr 14, 2026
9cf0637
Remove GetTypeInfo call
Exanite Apr 14, 2026
8c05ec7
Get the compilation once*
Exanite Apr 14, 2026
fe50783
Compare against _relevantIdentifiers set before calling GetSymbolInfo
Exanite Apr 14, 2026
9cb75e1
Skip using directives
Exanite Apr 14, 2026
5638221
Add ProfilingScope
Exanite Apr 14, 2026
a0ea115
Add comment on _relevantIdentifiers
Exanite Apr 14, 2026
ed941db
Fix field naming convention in ProfilingScope
Exanite Apr 14, 2026
8d5b978
Optimize document renaming in PrettifyNames
Exanite Apr 14, 2026
878a90f
Use normalized relative paths during conflict checking
Exanite Apr 14, 2026
9d52a44
Remove NormalizeWhitespace calls (much faster, but breaks generator)
Exanite Apr 15, 2026
aaafeff
Fix issue where the syntax tree gets corrupted due to reparsing
Exanite Apr 16, 2026
f63b15a
Edit comment and error message
Exanite Apr 16, 2026
46c2035
Avoid normalizing the syntax node twice when formatting
Exanite Apr 16, 2026
0d81c61
Avoid rebuilding the _relevantIdentifiers set for every document
Exanite Apr 16, 2026
bd2d79c
Move collections in ResolveConflictsProcessor to be closer to where t…
Exanite Apr 16, 2026
364015d
Preserve original line ending behavior
Exanite Apr 16, 2026
00d83bc
Update SDL to v3.44 from v3.2.4 to fix compile error
Exanite Apr 16, 2026
aa13c48
Revert change to get the compilation once during ModifyAllReferencesA…
Exanite Apr 17, 2026
e4f8325
Add comment on where the SDL Linux dependency list comes from
Exanite Apr 17, 2026
b0db2ba
Update dependency list
Exanite Apr 17, 2026
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
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<!-- Analyzers -->
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.12.0-beta1.25218.8" />
<!-- SilkTouch -->
<PackageVersion Include="ClangSharp.PInvokeGenerator" Version="20.1.2.4" />
<PackageVersion Include="ClangSharp.PInvokeGenerator" Version="21.1.8.3" />
<PackageVersion Include="CSharpier.Core" Version="0.30.2" />
<PackageVersion Include="Humanizer.Core" Version="2.14.1" />
<PackageVersion Include="Microsoft.Build.Locator" Version="1.11.1" />
Expand Down
2 changes: 1 addition & 1 deletion eng/submodules/sdl
Submodule sdl updated 1645 files
7 changes: 4 additions & 3 deletions sources/SDL/Native/build-linux-arm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ fi
if [[ ! -z ${GITHUB_ACTIONS+x} ]]; then
../../../eng/native/buildsystem/download-zig.py
export PATH="$PATH:$(readlink -f "../../../eng/native/buildsystem/zig")"
# Dependency list is from https://github.com/libsdl-org/SDL/blob/main/docs/README-linux.md#build-dependencies
sudo apt-get update
sudo apt-get install build-essential git make \
pkg-config cmake ninja-build gnome-desktop-testing libasound2-dev libpulse-dev \
libaudio-dev libjack-dev libsndio-dev libx11-dev libxext-dev \
libxrandr-dev libxcursor-dev libxfixes-dev libxi-dev libxss-dev \
libaudio-dev libfribidi-dev libjack-dev libsndio-dev libx11-dev libxext-dev \
libxrandr-dev libxcursor-dev libxfixes-dev libxi-dev libxss-dev libxtst-dev \
libxkbcommon-dev libdrm-dev libgbm-dev libgl1-mesa-dev libgles2-mesa-dev \
libegl1-mesa-dev libdbus-1-dev libibus-1.0-dev libudev-dev fcitx-libs-dev \
libegl1-mesa-dev libdbus-1-dev libibus-1.0-dev libudev-dev libthai-dev \
libpipewire-0.3-dev libwayland-dev libdecor-0-dev liburing-dev
fi
rm -rf build
Expand Down
7 changes: 4 additions & 3 deletions sources/SDL/Native/build-linux-arm64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ fi
if [[ ! -z ${GITHUB_ACTIONS+x} ]]; then
../../../eng/native/buildsystem/download-zig.py
export PATH="$PATH:$(readlink -f "../../../eng/native/buildsystem/zig")"
# Dependency list is from https://github.com/libsdl-org/SDL/blob/main/docs/README-linux.md#build-dependencies
sudo apt-get update
sudo apt-get install build-essential git make \
pkg-config cmake ninja-build gnome-desktop-testing libasound2-dev libpulse-dev \
libaudio-dev libjack-dev libsndio-dev libx11-dev libxext-dev \
libxrandr-dev libxcursor-dev libxfixes-dev libxi-dev libxss-dev \
libaudio-dev libfribidi-dev libjack-dev libsndio-dev libx11-dev libxext-dev \
libxrandr-dev libxcursor-dev libxfixes-dev libxi-dev libxss-dev libxtst-dev \
libxkbcommon-dev libdrm-dev libgbm-dev libgl1-mesa-dev libgles2-mesa-dev \
libegl1-mesa-dev libdbus-1-dev libibus-1.0-dev libudev-dev fcitx-libs-dev \
libegl1-mesa-dev libdbus-1-dev libibus-1.0-dev libudev-dev libthai-dev \
libpipewire-0.3-dev libwayland-dev libdecor-0-dev liburing-dev
fi
rm -rf build
Expand Down
7 changes: 4 additions & 3 deletions sources/SDL/Native/build-linux-x64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ fi
if [[ ! -z ${GITHUB_ACTIONS+x} ]]; then
../../../eng/native/buildsystem/download-zig.py
export PATH="$PATH:$(readlink -f "../../../eng/native/buildsystem/zig")"
# Dependency list is from https://github.com/libsdl-org/SDL/blob/main/docs/README-linux.md#build-dependencies
sudo apt-get update
sudo apt-get install build-essential git make \
pkg-config cmake ninja-build gnome-desktop-testing libasound2-dev libpulse-dev \
libaudio-dev libjack-dev libsndio-dev libx11-dev libxext-dev \
libxrandr-dev libxcursor-dev libxfixes-dev libxi-dev libxss-dev \
libaudio-dev libfribidi-dev libjack-dev libsndio-dev libx11-dev libxext-dev \
libxrandr-dev libxcursor-dev libxfixes-dev libxi-dev libxss-dev libxtst-dev \
libxkbcommon-dev libdrm-dev libgbm-dev libgl1-mesa-dev libgles2-mesa-dev \
libegl1-mesa-dev libdbus-1-dev libibus-1.0-dev libudev-dev fcitx-libs-dev \
libegl1-mesa-dev libdbus-1-dev libibus-1.0-dev libudev-dev libthai-dev \
libpipewire-0.3-dev libwayland-dev libdecor-0-dev liburing-dev
fi
rm -rf build
Expand Down
4 changes: 1 addition & 3 deletions sources/SilkTouch/SilkTouch/Mods/AddApiProfiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,7 @@ rewriter.Profile is null
logger.LogDebug("No profile identified for {}", path);
}

ctx.SourceProject = doc.WithSyntaxRoot(
rewriter.Visit(root).NormalizeWhitespace()
).Project;
ctx.SourceProject = doc.WithSyntaxRoot(rewriter.Visit(root)).Project;
rewriter.Profile = null;
}
}
Expand Down
12 changes: 5 additions & 7 deletions sources/SilkTouch/SilkTouch/Mods/AddOpaqueStructs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,10 @@ public Task ExecuteAsync(IModContext ctx, CancellationToken ct = default)
{
var qualified = name.LastIndexOf('.');
var ns =
qualified != -1
? ModUtils.NamespaceIntoIdentifierName(name.AsSpan()[..qualified])
: _defaultNamespaces.TryGetValue(ctx.JobKey, out var def)
? ModUtils.NamespaceIntoIdentifierName(def)
: null;
qualified != -1 ? ModUtils.NamespaceIntoIdentifierName(name.AsSpan()[..qualified])
: _defaultNamespaces.TryGetValue(ctx.JobKey, out var def)
? ModUtils.NamespaceIntoIdentifierName(def)
: null;
if (ns is null)
{
logger.LogWarning(
Expand Down Expand Up @@ -107,8 +106,7 @@ public Task ExecuteAsync(IModContext ctx, CancellationToken ct = default)
)
)
)
)
.NormalizeWhitespace(),
),
filePath: proj.FullPath(fname)
).Project;
}
Expand Down
9 changes: 2 additions & 7 deletions sources/SilkTouch/SilkTouch/Mods/AddVTables.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1454,8 +1454,7 @@ public async Task ExecuteAsync(IModContext ctx, CancellationToken ct = default)

rw.Reset();
proj = doc.WithSyntaxRoot(
rw.Visit(node)?.NormalizeWhitespace()
?? throw new InvalidOperationException("Visit returned null")
rw.Visit(node) ?? throw new InvalidOperationException("Visit returned null")
).Project;
if (rw.InterfacePartials.Count == 0)
{
Expand Down Expand Up @@ -1515,11 +1514,7 @@ rw.ClassName is not null
)
{
proj = proj
?.AddDocument(
Path.GetFileName(fname),
root.NormalizeWhitespace(),
filePath: proj.FullPath(fname)
)
?.AddDocument(Path.GetFileName(fname), root, filePath: proj.FullPath(fname))
.Project;
}

Expand Down
2 changes: 1 addition & 1 deletion sources/SilkTouch/SilkTouch/Mods/BakeSourceSets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ .. ctx
{
proj = proj.AddDocument(
Path.GetFileName(bakedPath),
bakedRoot.NormalizeWhitespace(),
bakedRoot,
// we can forgive the below nulls because RelativePath checks them, and returns null if they're null.
filePath: proj.FullPath(bakedPath)
).Project;
Expand Down
38 changes: 20 additions & 18 deletions sources/SilkTouch/SilkTouch/Mods/ChangeNamespace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ public Task<List<ResponseFile>> BeforeScrapeAsync(string key, List<ResponseFile>

rsps[i] = rsp with
{
GeneratorConfiguration = rsp.GeneratorConfiguration.ToWrapper() with {
GeneratorConfiguration = rsp.GeneratorConfiguration.ToWrapper() with
{
DefaultNamespace = def,
WithNamespaces = with,
},
Expand Down Expand Up @@ -91,7 +92,7 @@ public async Task ExecuteAsync(IModContext ctx, CancellationToken ct = default)
var doc =
proj!.GetDocument(docId) ?? throw new InvalidOperationException("Document missing");
proj = doc.WithSyntaxRoot(
rewriter.Visit(await doc.GetSyntaxRootAsync(ct))?.NormalizeWhitespace()
rewriter.Visit(await doc.GetSyntaxRootAsync(ct))
?? throw new InvalidOperationException("Visit returned null.")
).Project;
}
Expand All @@ -116,17 +117,16 @@ public Rewriter(
_usingsToAdd.Clear();
return base.VisitCompilationUnit(node) switch
{
CompilationUnitSyntax syntax
=> syntax.AddUsings(
_usingsToAdd
.Select(x => UsingDirective(ModUtils.NamespaceIntoIdentifierName(x)))
.Where(x =>
syntax.Usings.All(y => x.Name?.ToString() != y.Name?.ToString())
)
.ToArray()
),
CompilationUnitSyntax syntax => syntax.AddUsings(
_usingsToAdd
.Select(x => UsingDirective(ModUtils.NamespaceIntoIdentifierName(x)))
.Where(x =>
syntax.Usings.All(y => x.Name?.ToString() != y.Name?.ToString())
)
.ToArray()
),
{ } ret => ret,
null => null
null => null,
};
}

Expand All @@ -140,10 +140,11 @@ CompilationUnitSyntax syntax
}
return base.VisitNamespaceDeclaration(node) switch
{
NamespaceDeclarationSyntax syntax
=> syntax.WithName(ModUtils.NamespaceIntoIdentifierName(newNs)),
NamespaceDeclarationSyntax syntax => syntax.WithName(
ModUtils.NamespaceIntoIdentifierName(newNs)
),
{ } ret => ret,
null => null
null => null,
};
}

Expand All @@ -159,10 +160,11 @@ FileScopedNamespaceDeclarationSyntax node
}
return base.VisitFileScopedNamespaceDeclaration(node) switch
{
FileScopedNamespaceDeclarationSyntax syntax
=> syntax.WithName(ModUtils.NamespaceIntoIdentifierName(newNs)),
FileScopedNamespaceDeclarationSyntax syntax => syntax.WithName(
ModUtils.NamespaceIntoIdentifierName(newNs)
),
{ } ret => ret,
null => null
null => null,
};
}
}
Expand Down
11 changes: 3 additions & 8 deletions sources/SilkTouch/SilkTouch/Mods/Common/MSBuildModContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -308,13 +308,8 @@ private static async Task<string> ToNormalisedStringAsync(
CancellationToken ct = default
)
{
var result = await CodeFormatter.FormatAsync(
root.NormalizeWhitespace().SyntaxTree,
_opts,
ct
);
return !result.CompilationErrors.Any()
? result.Code
: root.NormalizeWhitespace(eol: "\n").ToFullString();
var normalizedRoot = root.NormalizeWhitespace(eol: "\n");
var result = await CodeFormatter.FormatAsync(normalizedRoot.SyntaxTree, _opts, ct);
return !result.CompilationErrors.Any() ? result.Code : normalizedRoot.ToFullString();
}
}
2 changes: 1 addition & 1 deletion sources/SilkTouch/SilkTouch/Mods/ExtractHandles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public override async Task ExecuteAsync(IModContext ctx, CancellationToken ct =
project = project
.AddDocument(
Path.GetFileName(relativePath),
node.NormalizeWhitespace(),
node,
filePath: project.FullPath(relativePath)
)
.Project;
Expand Down
8 changes: 3 additions & 5 deletions sources/SilkTouch/SilkTouch/Mods/ExtractNestedTyping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public override async Task ExecuteAsync(IModContext ctx, CancellationToken ct =
// This is also where extracted enums are processed.
rewriter.File = fname;
project = doc.WithSyntaxRoot(
rewriter.Visit(node)?.NormalizeWhitespace()
rewriter.Visit(node)
?? throw new InvalidOperationException("Rewriter returned null")
).Project;

Expand All @@ -110,8 +110,7 @@ rewriter.Namespace is not null
)
)
: SingletonList<MemberDeclarationSyntax>(newStruct)
)
.NormalizeWhitespace(),
),
filePath: project.FullPath(
$"{fname.AsSpan()[..fname.LastIndexOf('/')]}/{newStruct.Identifier}.gen.cs"
)
Expand Down Expand Up @@ -174,8 +173,7 @@ rewriter.Namespace is not null
.WithMembers(SingletonList(typeDecl))
)
: SingletonList(typeDecl)
)
.NormalizeWhitespace(),
),
filePath: project.FullPath($"{dir}/{identifier}.gen.cs")
)
.Project;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public async Task ExecuteAsync(IModContext ctx, CancellationToken ct = default)
var doc =
proj!.GetDocument(docId) ?? throw new InvalidOperationException("Document missing");
proj = doc.WithSyntaxRoot(
rewriter.Visit(await doc.GetSyntaxRootAsync(ct))?.NormalizeWhitespace()
rewriter.Visit(await doc.GetSyntaxRootAsync(ct))
?? throw new InvalidOperationException("Visit returned null.")
).Project;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,40 @@ public class IdentifierRenamingTransformer : LocationTransformer
{
private ISymbol symbol = null!;

private readonly IReadOnlyDictionary<string, List<(ISymbol Symbol, string NewName)>> newNameLookup;
private readonly IReadOnlyDictionary<
string,
List<(ISymbol Symbol, string NewName)>
> newNameLookup;

/// <summary>
/// Creates a new IdentifierRenamingTransformer.
/// </summary>
/// <param name="newNames">The new names for each symbol</param>
public IdentifierRenamingTransformer(IEnumerable<(ISymbol Symbol, string NewName)> newNames) : this(CreateNameLookup(newNames)) {}
public IdentifierRenamingTransformer(IEnumerable<(ISymbol Symbol, string NewName)> newNames)
: this(CreateNameLookup(newNames)) { }

/// <summary>
/// Creates a new IdentifierRenamingTransformer.
/// </summary>
/// <param name="newNameLookup">The new names for each symbol grouped by symbol name.</param>
public IdentifierRenamingTransformer(IReadOnlyDictionary<string, List<(ISymbol Symbol, string NewName)>> newNameLookup)
public IdentifierRenamingTransformer(
IReadOnlyDictionary<string, List<(ISymbol Symbol, string NewName)>> newNameLookup
)
{
this.newNameLookup = newNameLookup;
}

/// <summary>
/// Creates a name lookup dictionary designed for <see cref="IdentifierRenamingTransformer"/>.
/// </summary>
public static IReadOnlyDictionary<string, List<(ISymbol Symbol, string NewName)>> CreateNameLookup(IEnumerable<(ISymbol Symbol, string NewName)> names)
public static IReadOnlyDictionary<
string,
List<(ISymbol Symbol, string NewName)>
> CreateNameLookup(IEnumerable<(ISymbol Symbol, string NewName)> names)
{
return names.GroupBy(t => t.Symbol.Name).ToDictionary(group => group.Key, group => group.ToList());
return names
.GroupBy(t => t.Symbol.Name)
.ToDictionary(group => group.Key, group => group.ToList());
}

/// <inheritdoc />
Expand Down Expand Up @@ -68,7 +79,7 @@ private SyntaxToken GetRenamed(ISymbol symbol, SyntaxToken currentNameIdentifier
return currentNameIdentifier;
}

// ----- Types -----
// ----- Types -----

/// <inheritdoc />
public override SyntaxNode VisitClassDeclaration(ClassDeclarationSyntax node)
Expand Down
Loading
Loading