Skip to content
This repository was archived by the owner on Jun 10, 2024. It is now read-only.

fix: suppress warnings in generated code #11

Merged
merged 1 commit into from
Aug 27, 2023
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 @@ -128,6 +128,7 @@ public void OnTestPowerUp(int what) {
var source = generator.GeneratePowerUp(powerUp, superNode);

source.ShouldBe("""
#pragma warning disable
#nullable enable
using System.Collections;
using Godot;
Expand All @@ -150,6 +151,7 @@ public void OnTestPowerUp(int what)
}
}
#nullable disable
#pragma warning restore
""".NormalizeLineEndings());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public void GeneratesSuperNode() {
var source = generator.GenerateSuperNode(item);

source.ShouldBe("""
#pragma warning disable
#nullable enable
using Godot;
using SuperNodes.Types;
Expand Down Expand Up @@ -97,6 +98,7 @@ public override partial void _Notification(int what) {
}
}
#nullable disable
#pragma warning restore
""".NormalizeLineEndings());
}

Expand Down Expand Up @@ -249,6 +251,7 @@ public void GeneratesSuperNodeStaticReflectionTables() {
var source = generator.GenerateSuperNodeStatic(item, appliedPowerUps);

source.ShouldBe("""
#pragma warning disable
#nullable enable
using System;
using System.Collections;
Expand All @@ -269,6 +272,7 @@ partial class TestSuperNode : ISuperNode {
}
}
#nullable disable
#pragma warning restore
""".NormalizeLineEndings());
}
}
2 changes: 1 addition & 1 deletion SuperNodes.Types/Chickensoft.SuperNodes.Types.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<DebugType>portable</DebugType>

<Title>SuperNodes Types</Title>
<Version>1.4.0</Version>
<Version>1.5.0</Version>
<Description>Runtime types for SuperNodes.</Description>
<Copyright>© 2023 Chickensoft</Copyright>
<Authors>Chickensoft</Authors>
Expand Down
2 changes: 1 addition & 1 deletion SuperNodes/Chickensoft.SuperNodes.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<NoWarn>NU5128</NoWarn>

<Title>SuperNodes</Title>
<Version>1.4.0</Version>
<Version>1.5.0</Version>
<Description>Supercharge your Godot nodes with lifecycle-aware mixins, third party source generators, script introspection, and dynamic property manipulation — all without runtime reflection!</Description>
<Copyright>© 2023 Chickensoft Games</Copyright>
<Authors>Chickensoft</Authors>
Expand Down
2 changes: 2 additions & 0 deletions SuperNodes/src/PowerUpsFeature/PowerUpGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ public string GeneratePowerUp(PowerUp powerUp, SuperNode node) {
.NormalizeLineEndings("\n").Split('\n').ToImmutableArray();

return Format($$"""
#pragma warning disable
#nullable enable
{{usings}}

Expand All @@ -170,6 +171,7 @@ public string GeneratePowerUp(PowerUp powerUp, SuperNode node) {
{{source}}
{{If(node.Namespace is not null, "}")}}
#nullable disable
#pragma warning restore
""");
}
}
4 changes: 4 additions & 0 deletions SuperNodes/src/SuperNodesFeature/SuperNodeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ GenerationItem item
.GenerateNotificationHandlers(node.NotificationHandlers);

return Format($$"""
#pragma warning disable
#nullable enable
using Godot;
using SuperNodes.Types;
Expand Down Expand Up @@ -96,6 +97,7 @@ public override partial void _Notification(int what) {
"}"
)}}
#nullable disable
#pragma warning restore
""").Clean();
}

Expand Down Expand Up @@ -153,6 +155,7 @@ public string GenerateSuperNodeStatic(
.GenerateSetPropertyOrField(node.Name, propsAndFields);

return Format($$"""
#pragma warning disable
#nullable enable
{{usings}}

Expand All @@ -174,6 +177,7 @@ partial class {{node.Name}} : ISuperNode {
"}"
)}}
#nullable disable
#pragma warning restore
""");
}
}