Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: aliasing built-in types #17

Merged
merged 2 commits into from
Dec 17, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public partial class TypeRegistry : Chickensoft.Introspection.ITypeRegistry {
[typeof(Chickensoft.Introspection.Generator.Tests.TestCases.ConcreteChildOne)] = new Chickensoft.Introspection.IdentifiableTypeMetadata("ConcreteChildOne", static (r) => r.Receive<Chickensoft.Introspection.Generator.Tests.TestCases.ConcreteChildOne>(), static () => System.Activator.CreateInstance<Chickensoft.Introspection.Generator.Tests.TestCases.ConcreteChildOne>(), new Chickensoft.Introspection.Generator.Tests.TestCases.ConcreteChildOne.MetatypeMetadata(), "concrete_child_one", 1),
[typeof(Chickensoft.Introspection.Generator.Tests.TestCases.ConcreteChildTwo)] = new Chickensoft.Introspection.IdentifiableTypeMetadata("ConcreteChildTwo", static (r) => r.Receive<Chickensoft.Introspection.Generator.Tests.TestCases.ConcreteChildTwo>(), static () => System.Activator.CreateInstance<Chickensoft.Introspection.Generator.Tests.TestCases.ConcreteChildTwo>(), new Chickensoft.Introspection.Generator.Tests.TestCases.ConcreteChildTwo.MetatypeMetadata(), "concrete_child_two", 1),
[typeof(Chickensoft.Introspection.Generator.Tests.TestCases.DerivedModel)] = new Chickensoft.Introspection.IntrospectiveTypeMetadata("DerivedModel", static (r) => r.Receive<Chickensoft.Introspection.Generator.Tests.TestCases.DerivedModel>(), static () => System.Activator.CreateInstance<Chickensoft.Introspection.Generator.Tests.TestCases.DerivedModel>(), new Chickensoft.Introspection.Generator.Tests.TestCases.DerivedModel.MetatypeMetadata(), 1),
[typeof(Chickensoft.Introspection.Generator.Tests.TestCases.ExampleStruct)] = new Chickensoft.Introspection.ConcreteTypeMetadata("ExampleStruct", static (r) => r.Receive<Chickensoft.Introspection.Generator.Tests.TestCases.ExampleStruct>(), static () => System.Activator.CreateInstance<Chickensoft.Introspection.Generator.Tests.TestCases.ExampleStruct>()),
[typeof(Chickensoft.Introspection.Generator.Tests.TestCases.GenericStruct<>)] = new Chickensoft.Introspection.TypeMetadata("GenericStruct<T>"),
[typeof(Chickensoft.Introspection.Generator.Tests.TestCases.InitArgsModel)] = new Chickensoft.Introspection.IdentifiableTypeMetadata("InitArgsModel", static (r) => r.Receive<Chickensoft.Introspection.Generator.Tests.TestCases.InitArgsModel>(), static () => System.Activator.CreateInstance<Chickensoft.Introspection.Generator.Tests.TestCases.InitArgsModel>(), new Chickensoft.Introspection.Generator.Tests.TestCases.InitArgsModel.MetatypeMetadata(), "init_args_model", 1),
[typeof(Chickensoft.Introspection.Generator.Tests.TestCases.JunkAttribute)] = new Chickensoft.Introspection.ConcreteTypeMetadata("JunkAttribute", static (r) => r.Receive<Chickensoft.Introspection.Generator.Tests.TestCases.JunkAttribute>(), static () => System.Activator.CreateInstance<Chickensoft.Introspection.Generator.Tests.TestCases.JunkAttribute>()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@

<!-- Tracks generator performance when dotnet build /binaryLogger -->
<ReportAnalyzer>true</ReportAnalyzer>

<NoWarn>CA1010;NU1903</NoWarn>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.4.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.12.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma warning disable IDE0005 // Using directive is unnecessary.
global using MyExampleStruct =
Chickensoft.Introspection.Generator.Tests.TestCases.ExampleStruct;
global using MyExampleType = int;
#pragma warning restore IDE0005 // Using directive is unnecessary.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
namespace Chickensoft.Introspection.Generator.Tests.TestCases;

public readonly record struct ExampleStruct;
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

<!-- The following libraries include the source generator interfaces and types we need -->
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.4.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.12.0" PrivateAssets="all" />
<PackageReference Include="IsExternalInit" Version="1.0.3" PrivateAssets="all">
</PackageReference>
</ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion Chickensoft.Introspection.Generator/src/TypeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
/// https://github.com/dotnet/runtime/issues/31326
/// </summary>
[Generator]
public class TypeGenerator : IIncrementalGenerator {

Check warning on line 30 in Chickensoft.Introspection.Generator/src/TypeGenerator.cs

View workflow job for this annotation

GitHub Actions / 🧪 Evaluate Tests on macos-latest

'Chickensoft.Introspection.Generator.TypeGenerator': A project containing analyzers or source generators should specify the property '<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>'

Check warning on line 30 in Chickensoft.Introspection.Generator/src/TypeGenerator.cs

View workflow job for this annotation

GitHub Actions / 🧪 Evaluate Tests on macos-latest

'Chickensoft.Introspection.Generator.TypeGenerator': A project containing analyzers or source generators should specify the property '<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>'
public void Initialize(IncrementalGeneratorInitializationContext context) {
// If you need to debug the source generator, uncomment the following line
// and use Visual Studio 2022 on Windows to attach to debugging next time
Expand Down Expand Up @@ -494,7 +494,8 @@
public static UsingDirective GetUsing(UsingDirectiveSyntax @using) =>
new(
Alias: @using.Alias?.Name.NormalizeWhitespace().ToString(),
Name: @using.Name.NormalizeWhitespace().ToString(),
Name: @using.Name?.NormalizeWhitespace().ToString()
?? @using.NamespaceOrType.NormalizeWhitespace().ToString(),
IsGlobal: @using.GlobalKeyword is { ValueText: "global" },
IsStatic: @using.StaticKeyword is { ValueText: "static" },
IsAlias: @using.Alias != default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

<!-- Tracks generator performance when dotnet build /binaryLogger -->
<ReportAnalyzer>true</ReportAnalyzer>

<NoWarn>NU1903</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"sdk": {
"version": "7.0.404",
"version": "9.0.100",
"rollForward": "latestMinor"
},
"msbuild-sdks": {
"Godot.NET.Sdk": "4.2.2"
}
}
}
Loading