Skip to content

Commit d565a47

Browse files
author
Joanna May
authored
Merge pull request #17 from chickensoft-games/fix/global-using-struct
fix: global using predefined types
2 parents c2c8136 + e515f59 commit d565a47

File tree

8 files changed

+19
-5
lines changed

8 files changed

+19
-5
lines changed

Chickensoft.Introspection.Generator.Tests/.generated/Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.TypeGenerator/TypeRegistry.g.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public partial class TypeRegistry : Chickensoft.Introspection.ITypeRegistry {
4343
[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),
4444
[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),
4545
[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),
46+
[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>()),
4647
[typeof(Chickensoft.Introspection.Generator.Tests.TestCases.GenericStruct<>)] = new Chickensoft.Introspection.TypeMetadata("GenericStruct<T>"),
4748
[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),
4849
[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>()),

Chickensoft.Introspection.Generator.Tests/Chickensoft.Introspection.Generator.Tests.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@
1515

1616
<!-- Tracks generator performance when dotnet build /binaryLogger -->
1717
<ReportAnalyzer>true</ReportAnalyzer>
18+
19+
<NoWarn>CA1010;NU1903</NoWarn>
1820
</PropertyGroup>
1921

2022
<ItemGroup>
21-
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.4.0" />
23+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.12.0" />
2224
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
2325
<PackageReference Include="xunit" Version="2.4.1" />
2426
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#pragma warning disable IDE0005 // Using directive is unnecessary.
2+
global using MyExampleStruct =
3+
Chickensoft.Introspection.Generator.Tests.TestCases.ExampleStruct;
4+
global using MyExampleType = int;
5+
#pragma warning restore IDE0005 // Using directive is unnecessary.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
namespace Chickensoft.Introspection.Generator.Tests.TestCases;
2+
3+
public readonly record struct ExampleStruct;

Chickensoft.Introspection.Generator/Chickensoft.Introspection.Generator.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
<!-- The following libraries include the source generator interfaces and types we need -->
4545
<ItemGroup>
46-
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.4.0" PrivateAssets="all" />
46+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.12.0" PrivateAssets="all" />
4747
<PackageReference Include="IsExternalInit" Version="1.0.3" PrivateAssets="all">
4848
</PackageReference>
4949
</ItemGroup>

Chickensoft.Introspection.Generator/src/TypeGenerator.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,8 @@ TypeDeclarationSyntax type
494494
public static UsingDirective GetUsing(UsingDirectiveSyntax @using) =>
495495
new(
496496
Alias: @using.Alias?.Name.NormalizeWhitespace().ToString(),
497-
Name: @using.Name.NormalizeWhitespace().ToString(),
497+
Name: @using.Name?.NormalizeWhitespace().ToString()
498+
?? @using.NamespaceOrType.NormalizeWhitespace().ToString(),
498499
IsGlobal: @using.GlobalKeyword is { ValueText: "global" },
499500
IsStatic: @using.StaticKeyword is { ValueText: "static" },
500501
IsAlias: @using.Alias != default

Chickensoft.Introspection.Tests/Chickensoft.Introspection.Tests.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
<!-- Tracks generator performance when dotnet build /binaryLogger -->
1818
<ReportAnalyzer>true</ReportAnalyzer>
19+
20+
<NoWarn>NU1903</NoWarn>
1921
</PropertyGroup>
2022

2123
<ItemGroup>

global.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"sdk": {
3-
"version": "7.0.404",
3+
"version": "9.0.100",
44
"rollForward": "latestMinor"
55
},
66
"msbuild-sdks": {
77
"Godot.NET.Sdk": "4.2.2"
88
}
9-
}
9+
}

0 commit comments

Comments
 (0)