mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
[SwapEndianGenerator] Ensure type name goes to filename to add uniqueness.
This commit is contained in:
@@ -106,7 +106,12 @@ public class SwapEndianGenerator : IIncrementalGenerator
|
|||||||
string generatedSource =
|
string generatedSource =
|
||||||
GenerateSwapEndianMethod(structName, namespaceName, containingTypes, source.fieldTypes);
|
GenerateSwapEndianMethod(structName, namespaceName, containingTypes, source.fieldTypes);
|
||||||
|
|
||||||
context.AddSource($"{structName}_SwapEndian.g.cs", SourceText.From(generatedSource, Encoding.UTF8));
|
// Create unique file name by including containing types
|
||||||
|
string fileName = containingTypes.Count > 0
|
||||||
|
? $"{string.Join("_", containingTypes.Select(t => t.Name))}_{structName}_SwapEndian.g.cs"
|
||||||
|
: $"{structName}_SwapEndian.g.cs";
|
||||||
|
|
||||||
|
context.AddSource(fileName, SourceText.From(generatedSource, Encoding.UTF8));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string GetNamespace(SyntaxNode syntax)
|
private static string GetNamespace(SyntaxNode syntax)
|
||||||
@@ -447,4 +452,5 @@ public class SwapEndianGenerator : IIncrementalGenerator
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
""";
|
""";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user