Skip to content

Commit

Permalink
Add WritesWarningDisableCs0618, WritesWarningRestoreCs0618
Browse files Browse the repository at this point in the history
  • Loading branch information
trejjam committed Aug 26, 2024
1 parent e519975 commit df1010d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Kiota.Builder/Writers/CSharp/CodeBlockEndWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public override void WriteCodeElement(BlockEnd codeElement, LanguageWriter write
if (codeElement?.Parent is CodeClass codeClass && codeClass.Parent is CodeNamespace)
{
writer.CloseBlock();
conventions.WritePragmaRestore(writer, CSharpConventionService.CS0618);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ public void WritesSimpleDeclaration()
Assert.Contains("public partial class", result);
}

[Fact]
public void WritesWarningDisableCs0618()
{
codeElementWriter.WriteCodeElement(parentClass.StartBlock, writer);
var result = tw.ToString();
Assert.Contains("#pragma warning disable CS0618", result);
}

[Fact]
public void WritesImplementation()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ public void ClosesNestedClasses()
codeElementWriter.WriteCodeElement(child.EndBlock, writer);
var result = tw.ToString();
Assert.Equal(1, result.Count(x => x == '}'));
Assert.DoesNotContain("#pragma warning restore CS0618", result);
}
[Fact]
public void WritesWarningRestoreCs0618()
{
codeElementWriter.WriteCodeElement(parentClass.EndBlock, writer);
var result = tw.ToString();
Assert.Contains("#pragma warning restore CS0618", result);
}
[Fact]
public void ClosesNonNestedClasses()
Expand Down

0 comments on commit df1010d

Please sign in to comment.