diff --git a/WoWsShipBuilder.Data.Generator.Test/AssertionMethodAttribute.cs b/WoWsShipBuilder.Data.Generator.Test/AssertionMethodAttribute.cs new file mode 100644 index 000000000..c3e23e5dc --- /dev/null +++ b/WoWsShipBuilder.Data.Generator.Test/AssertionMethodAttribute.cs @@ -0,0 +1,8 @@ +using System; + +namespace WoWsShipBuilder.Data.Generator.Test; + +[AttributeUsage(AttributeTargets.Method)] +public class AssertionMethodAttribute : Attribute +{ +} diff --git a/WoWsShipBuilder.Data.Generator.Test/DataElementAnalyzerTests/DataElementAnalyzerTest.cs b/WoWsShipBuilder.Data.Generator.Test/DataElementAnalyzerTests/DataElementAnalyzerTest.cs index 802f37b3b..6ca8d4bd4 100644 --- a/WoWsShipBuilder.Data.Generator.Test/DataElementAnalyzerTests/DataElementAnalyzerTest.cs +++ b/WoWsShipBuilder.Data.Generator.Test/DataElementAnalyzerTests/DataElementAnalyzerTest.cs @@ -34,6 +34,7 @@ public partial record TestRecord : DataContainerBase await CreateTest(source).RunAsync(); } + [AssertionMethod] private static CSharpAnalyzerTest CreateTest(string source) { const string baseClass = """ diff --git a/WoWsShipBuilder.Data.Generator.Test/DataElementAnalyzerTests/KeyValueUnit.cs b/WoWsShipBuilder.Data.Generator.Test/DataElementAnalyzerTests/KeyValueUnit.cs index e933b470c..76fc965fc 100644 --- a/WoWsShipBuilder.Data.Generator.Test/DataElementAnalyzerTests/KeyValueUnit.cs +++ b/WoWsShipBuilder.Data.Generator.Test/DataElementAnalyzerTests/KeyValueUnit.cs @@ -114,7 +114,7 @@ namespace Test; [DataContainer] public partial record TestRecord : DataContainerBase { - [DataElementType(DataElementTypes.KeyValueUnit, UnitKey = "Test", ArgumentsTextKind = TextKind.LocalizationKey)] + [DataElementType(DataElementTypes.KeyValueUnit, UnitKey = "Test", ArgumentsTextKind = TextKind.AppLocalizationKey)] public decimal {|SB1003:Prop1|} { get; set; } } """; diff --git a/WoWsShipBuilder.Data.Generator.Test/DataElementGeneratorTests/DataElementGeneratorTest.cs b/WoWsShipBuilder.Data.Generator.Test/DataElementGeneratorTests/DataElementGeneratorTest.cs index d76385e11..45f6ae3c7 100644 --- a/WoWsShipBuilder.Data.Generator.Test/DataElementGeneratorTests/DataElementGeneratorTest.cs +++ b/WoWsShipBuilder.Data.Generator.Test/DataElementGeneratorTests/DataElementGeneratorTest.cs @@ -13,6 +13,7 @@ namespace WoWsShipBuilder.Data.Generator.Test.DataElementGeneratorTests; [SuppressMessage("Maintainability", "S2699", Justification = "false-positive since sonarlint does not recognize custom CreateTest method")] public partial class DataElementGeneratorTest { + [AssertionMethod] private static CSharpSourceGeneratorTest CreateTest(string source, string expected) { const string baseClass = """ diff --git a/WoWsShipBuilder.Data.Generator.Test/PropertyChangedGeneratorTests/PropertyChangedGeneratorTest.cs b/WoWsShipBuilder.Data.Generator.Test/PropertyChangedGeneratorTests/PropertyChangedGeneratorTest.cs index 12f223f65..d802ddf98 100644 --- a/WoWsShipBuilder.Data.Generator.Test/PropertyChangedGeneratorTests/PropertyChangedGeneratorTest.cs +++ b/WoWsShipBuilder.Data.Generator.Test/PropertyChangedGeneratorTests/PropertyChangedGeneratorTest.cs @@ -1,10 +1,12 @@ -using Microsoft.CodeAnalysis.CSharp.Testing; +using System.Diagnostics.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp.Testing; using Microsoft.CodeAnalysis.Testing.Verifiers; using WoWsShipBuilder.Data.Generator.PropertyChangedGenerator; namespace WoWsShipBuilder.Data.Generator.Test.PropertyChangedGeneratorTests; [TestFixture] +[SuppressMessage("Maintainability", "S2699", Justification = "false-positive since sonarlint does not recognize RunAsync method from generator test framework")] public class PropertyChangedGeneratorTest { private const string AttributeClass = """ diff --git a/WoWsShipBuilder.Data.Generator/Utilities/SourceBuilder.cs b/WoWsShipBuilder.Data.Generator/Utilities/SourceBuilder.cs index 016ac682f..23f400564 100644 --- a/WoWsShipBuilder.Data.Generator/Utilities/SourceBuilder.cs +++ b/WoWsShipBuilder.Data.Generator/Utilities/SourceBuilder.cs @@ -11,7 +11,7 @@ internal sealed class SourceBuilder private readonly StringBuilder sb; - private int indent; + private int currentIndent; private LastAction lastAction; @@ -141,13 +141,13 @@ private void BlockOpen(string? line = null) private SourceBuilder DecreaseIndent() { - --this.indent; + --this.currentIndent; return this; } private SourceBuilder IncreaseIndent() { - ++this.indent; + ++this.currentIndent; return this; } @@ -174,7 +174,7 @@ private SourceBuilder Append(string? text) private SourceBuilder AppendIndent() { - this.sb.Append(' ', this.indent * IndentSize); + this.sb.Append(' ', this.currentIndent * IndentSize); return this; }