Skip to content

Commit

Permalink
Add Unit Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dvoituron committed Nov 28, 2024
1 parent e734fb1 commit c1fafcb
Show file tree
Hide file tree
Showing 8 changed files with 247 additions and 1 deletion.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,74 @@ public async Task SingleString_PublicVisualBasicAsync(bool publicResource)
[/0/Resources.resx]
build_metadata.AdditionalFiles.Public = {(publicResource ? "true" : "false")}
"),
},
},
}.AddGeneratedSources().RunAsync();
}

[Theory]
[InlineData("")]
[InlineData("CS1591")]
[InlineData("CS1591, IDE0010")]
[InlineData(" , CS1591, IDE0010 ")]
public async Task SingleString_NoWarnsCSharpAsync(string noWarns)
{
var code = ResxHeader
+ @" <data name=""Name"" xml:space=""preserve"">
<value>value</value>
<comment>comment</comment>
</data>"
+ ResxFooter;

var id = string.Join("_", noWarns.Replace(" ", "").Split(",", System.StringSplitOptions.TrimEntries | System.StringSplitOptions.RemoveEmptyEntries));

await new VerifyCS.Test(identifier: id)
{
TestState =
{
AdditionalFiles = { ("/0/Resources.resx", code) },
AnalyzerConfigFiles =
{
("/.globalconfig", $@"
is_global = true
[/0/Resources.resx]
build_metadata.AdditionalFiles.NoWarns = {noWarns}
"),
},
},
}.AddGeneratedSources().RunAsync();
}

[Theory]
[InlineData("")]
[InlineData("CS1591")]
[InlineData("CS1591, IDE0010")]
[InlineData(" , CS1591, IDE0010 ")]
public async Task SingleString_NoWarnsVisualBasicAsync(string noWarns)
{
var code = ResxHeader
+ @" <data name=""Name"" xml:space=""preserve"">
<value>value</value>
<comment>comment</comment>
</data>"
+ ResxFooter;

var id = string.Join("_", noWarns.Replace(" ", "").Split(",", System.StringSplitOptions.TrimEntries | System.StringSplitOptions.RemoveEmptyEntries));

await new VerifyVB.Test(identifier: id)
{
TestState =
{
AdditionalFiles = { ("/0/Resources.resx", code) },
AnalyzerConfigFiles =
{
("/.globalconfig", $@"
is_global = true
[/0/Resources.resx]
build_metadata.AdditionalFiles.NoWarns = {noWarns}
"),
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
var noWarns = Array.Empty<string>();
if (options.TryGetValue("build_metadata.AdditionalFiles.NoWarns", out var noWarnsText))
{
noWarns = noWarnsText.Split([',', ';'], StringSplitOptions.RemoveEmptyEntries) ?? [];
noWarns = noWarnsText.Split([',', ';'], StringSplitOptions.RemoveEmptyEntries).Select(i => i.Trim()).ToArray() ?? [];
}

return new[]
Expand Down

0 comments on commit c1fafcb

Please sign in to comment.