Skip to content

Commit

Permalink
Suppress false positives. Updating analyzers is tracked by #28672.
Browse files Browse the repository at this point in the history
  • Loading branch information
333fred committed Oct 20, 2022
1 parent 273e215 commit 960fda4
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ public static IEnumerable<object[]> GetInvalidParametersTestData()
}

[Theory]
#pragma warning disable CA1825 // Avoid zero-length array allocations. https://github.com/dotnet/sdk/issues/28672
[MemberData(nameof(GetInvalidParametersTestData))]
#pragma warning restore CA1825 // Avoid zero-length array allocations.
// invalid params:
// [0] name / value - Kind
// [1] canonical
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ public void Create_CanParseTemplateWithOptions()
}

[Theory]
#pragma warning disable CA1825 // Avoid zero-length array allocations. https://github.com/dotnet/sdk/issues/28672
[MemberData(nameof(CanEvaluateTemplateToRunData))]
#pragma warning restore CA1825 // Avoid zero-length array allocations.
internal void Create_CanEvaluateTemplateToRun(string command, string templateSet, string? defaultLanguage, string? expectedIdentitiesStr)
{
TemplateGroup templateGroup = TemplateGroup.FromTemplateList(
Expand Down Expand Up @@ -124,7 +126,9 @@ internal void Create_CanValidateOptionUsage_InNewCommand(string command, string?
}

[Theory]
#pragma warning disable CA1825 // Avoid zero-length array allocations. https://github.com/dotnet/sdk/issues/28672
[MemberData(nameof(CanParseTemplateOptionsData))]
#pragma warning restore CA1825 // Avoid zero-length array allocations.
internal void Create_CanParseTemplateOptions(string command, string parameterName, string parameterType, string? defaultValue, string? defaultIfNoOptionValue, string? expectedValue)
{
//unique case for dotnet new create
Expand Down Expand Up @@ -165,7 +169,9 @@ internal void Create_CanParseTemplateOptions(string command, string parameterNam
}

[Theory]
#pragma warning disable CA1825 // Avoid zero-length array allocations. https://github.com/dotnet/sdk/issues/28672
[MemberData(nameof(CanParseChoiceTemplateOptionsData))]
#pragma warning restore CA1825 // Avoid zero-length array allocations.
internal void Create_CanParseChoiceTemplateOptions(string command, string parameterName, string parameterValues, string? defaultIfNoOptionValue, string? expectedValue)
{
MockTemplateInfo template = new MockTemplateInfo("foo", identity: "foo.1", groupIdentity: "foo.group")
Expand Down Expand Up @@ -200,7 +206,9 @@ internal void Create_CanParseChoiceTemplateOptions(string command, string parame
}

[Theory]
#pragma warning disable CA1825 // Avoid zero-length array allocations. https://github.com/dotnet/sdk/issues/28672
[MemberData(nameof(CanDetectParseErrorsTemplateOptionsData))]
#pragma warning restore CA1825 // Avoid zero-length array allocations.
internal void Create_CanDetectParseErrorsTemplateOptions(
string command,
string parameterName,
Expand Down Expand Up @@ -234,7 +242,9 @@ internal void Create_CanDetectParseErrorsTemplateOptions(
}

[Theory]
#pragma warning disable CA1825 // Avoid zero-length array allocations. https://github.com/dotnet/sdk/issues/28672
[MemberData(nameof(CanDetectParseErrorsChoiceTemplateOptionsData))]
#pragma warning restore CA1825 // Avoid zero-length array allocations.
internal void Create_CanDetectParseErrorsChoiceTemplateOptions(
string command,
string parameterName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,9 @@ public void Instantiate_CanParseTemplateWithOptions()
};

[Theory]
#pragma warning disable CA1825 // Avoid zero-length array allocations. https://github.com/dotnet/sdk/issues/28672
[MemberData(nameof(CanEvaluateTemplateToRunData))]
#pragma warning restore CA1825 // Avoid zero-length array allocations.
internal void CanEvaluateTemplateToRun(string command, string templateSet, string? defaultLanguage, string? expectedIdentitiesStr)
{
TemplateGroup templateGroup = TemplateGroup.FromTemplateList(
Expand Down Expand Up @@ -304,7 +306,9 @@ internal void CanParseNameOption(string command, string? expectedValue)
};

[Theory]
#pragma warning disable CA1825 // Avoid zero-length array allocations. https://github.com/dotnet/sdk/issues/28672
[MemberData(nameof(CanParseTemplateOptionsData))]
#pragma warning restore CA1825 // Avoid zero-length array allocations.
internal void CanParseTemplateOptions(string command, string parameterName, string parameterType, string? defaultValue, string? defaultIfNoOptionValue, string? expectedValue)
{
MockTemplateInfo template = new MockTemplateInfo("foo", identity: "foo.1", groupIdentity: "foo.group")
Expand Down Expand Up @@ -348,7 +352,9 @@ internal void CanParseTemplateOptions(string command, string parameterName, stri
};

[Theory]
#pragma warning disable CA1825 // Avoid zero-length array allocations. https://github.com/dotnet/sdk/issues/28672
[MemberData(nameof(CanParseChoiceTemplateOptionsData))]
#pragma warning restore CA1825 // Avoid zero-length array allocations.
internal void CanParseChoiceTemplateOptions(string command, string parameterName, string parameterValues, string? defaultIfNoOptionValue, string? expectedValue)
{
MockTemplateInfo template = new MockTemplateInfo("foo", identity: "foo.1", groupIdentity: "foo.group")
Expand Down Expand Up @@ -392,7 +398,9 @@ internal void CanParseChoiceTemplateOptions(string command, string parameterName
};

[Theory]
#pragma warning disable CA1825 // Avoid zero-length array allocations. https://github.com/dotnet/sdk/issues/28672
[MemberData(nameof(CanParseMultiChoiceTemplateOptionsData))]
#pragma warning restore CA1825 // Avoid zero-length array allocations.
internal void CanParseMultiChoiceTemplateOptions(string command, string parameterName, string parameterValues, string? defaultIfNoOptionValue, string? expectedValue)
{
MockTemplateInfo template = new MockTemplateInfo("foo", identity: "foo.1", groupIdentity: "foo.group")
Expand Down Expand Up @@ -455,7 +463,9 @@ internal void CanParseMultiChoiceTemplateOptions(string command, string paramete
};

[Theory]
#pragma warning disable CA1825 // Avoid zero-length array allocations. https://github.com/dotnet/sdk/issues/28672
[MemberData(nameof(CanDetectParseErrorsTemplateOptionsData))]
#pragma warning restore CA1825 // Avoid zero-length array allocations.
internal void CanDetectParseErrorsTemplateOptions(
string command,
string parameterName,
Expand Down Expand Up @@ -498,7 +508,9 @@ internal void CanDetectParseErrorsTemplateOptions(
};

[Theory]
#pragma warning disable CA1825 // Avoid zero-length array allocations. https://github.com/dotnet/sdk/issues/28672
[MemberData(nameof(CanDetectParseErrorsChoiceTemplateOptionsData))]
#pragma warning restore CA1825 // Avoid zero-length array allocations.
internal void CanDetectParseErrorsChoiceTemplateOptions(
string command,
string parameterName,
Expand Down
8 changes: 8 additions & 0 deletions src/Tests/dotnet-new.Tests/CommonTemplatesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,9 @@ public void GlobalJsonTests(string expectedContent, params string[] parameters)

[Theory]
//creates all possible combinations for supported templates, language versions and frameworks
#pragma warning disable CA1825 // Avoid zero-length array allocations. https://github.com/dotnet/sdk/issues/28672
[MemberData(nameof(TopLevelProgramSupport_Data))]
#pragma warning restore CA1825 // Avoid zero-length array allocations.
public void TopLevelProgramSupport(string name, bool buildPass, string? framework, string? langVersion, bool supportsFeature)
{
string workingDir = CreateTemporaryFolder(folderName: $"{name}-{langVersion ?? "null"}-{framework ?? "null"}");
Expand Down Expand Up @@ -538,7 +540,9 @@ static void Main(string[] args)

[Theory]
//creates all possible combinations for supported templates, language versions and frameworks
#pragma warning disable CA1825 // Avoid zero-length array allocations. https://github.com/dotnet/sdk/issues/28672
[MemberData(nameof(NullableSupport_Data))]
#pragma warning restore CA1825 // Avoid zero-length array allocations.
public void NullableSupport(string name, bool buildPass, string? framework, string? langVersion, bool supportsFeature)
{
string workingDir = CreateTemporaryFolder(folderName: $"{name}-{langVersion ?? "null"}-{framework ?? "null"}");
Expand Down Expand Up @@ -640,7 +644,9 @@ public void NullableSupport(string name, bool buildPass, string? framework, stri

[Theory]
//creates all possible combinations for supported templates, language versions and frameworks
#pragma warning disable CA1825 // Avoid zero-length array allocations. https://github.com/dotnet/sdk/issues/28672
[MemberData(nameof(ImplicitUsingsSupport_Data))]
#pragma warning restore CA1825 // Avoid zero-length array allocations.
public void ImplicitUsingsSupport(string name, bool buildPass, string? framework, string? langVersion, bool supportsFeature)
{
string workingDir = CreateTemporaryFolder(folderName: $"{name}-{langVersion ?? "null"}-{framework ?? "null"}");
Expand Down Expand Up @@ -727,7 +733,9 @@ public void ImplicitUsingsSupport(string name, bool buildPass, string? framework

[Theory]
//creates all possible combinations for supported templates, language versions and frameworks
#pragma warning disable CA1825 // Avoid zero-length array allocations.https://github.com/dotnet/sdk/issues/28672
[MemberData(nameof(FileScopedNamespacesSupport_Data))]
#pragma warning restore CA1825 // Avoid zero-length array allocations.
public void FileScopedNamespacesSupport(string name, bool pass, string? framework, string? langVersion, bool supportsFeature)
{
string workingDir = CreateTemporaryFolder(folderName: $"{name}-{langVersion ?? "null"}-{framework ?? "null"}");
Expand Down

0 comments on commit 960fda4

Please sign in to comment.