Skip to content

Commit

Permalink
Remove one more unnecessary try/catch
Browse files Browse the repository at this point in the history
  • Loading branch information
Youssef1313 authored Nov 13, 2024
1 parent 0007764 commit c3819e2
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions src/Adapter/MSTest.TestAdapter/Discovery/AssemblyEnumerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -409,24 +409,22 @@ private static bool ProcessTestDataSourceTests(UnitTestElement test, ReflectionT

// This code is to discover tests. To run the tests code is in TestMethodRunner.ExecuteDataSourceBasedTests.
// Any change made here should be reflected in TestMethodRunner.ExecuteDataSourceBasedTests as well.
try
{
data = dataSource.GetData(methodInfo);
data = dataSource.GetData(methodInfo);

if (!data.Any())
if (!data.Any())
{
if (MSTestSettings.CurrentSettings.ConsiderEmptyDataSourceAsInconclusive)
{
throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, FrameworkMessages.DynamicDataIEnumerableEmpty, "GetData", dataSource.GetType().Name));
UnitTestElement discoveredTest = test.Clone();
// Make the test not data driven, because it had no data.
discoveredTest.TestMethod.DataType = DynamicDataType.None;
discoveredTest.DisplayName = dataSource.GetDisplayName(methodInfo, null) ?? discoveredTest.DisplayName;

Check failure on line 422 in src/Adapter/MSTest.TestAdapter/Discovery/AssemblyEnumerator.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build Linux Debug)

src/Adapter/MSTest.TestAdapter/Discovery/AssemblyEnumerator.cs#L422

src/Adapter/MSTest.TestAdapter/Discovery/AssemblyEnumerator.cs(422,1): error IDE0055: (NETCORE_ENGINEERING_TELEMETRY=Build) Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 422 in src/Adapter/MSTest.TestAdapter/Discovery/AssemblyEnumerator.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build Linux Debug)

src/Adapter/MSTest.TestAdapter/Discovery/AssemblyEnumerator.cs#L422

src/Adapter/MSTest.TestAdapter/Discovery/AssemblyEnumerator.cs(422,1): error SA1028: (NETCORE_ENGINEERING_TELEMETRY=Build) Code should not contain trailing whitespace (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1028.md)

Check failure on line 422 in src/Adapter/MSTest.TestAdapter/Discovery/AssemblyEnumerator.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build Linux Debug)

src/Adapter/MSTest.TestAdapter/Discovery/AssemblyEnumerator.cs#L422

src/Adapter/MSTest.TestAdapter/Discovery/AssemblyEnumerator.cs(422,1): error IDE0055: (NETCORE_ENGINEERING_TELEMETRY=Build) Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 422 in src/Adapter/MSTest.TestAdapter/Discovery/AssemblyEnumerator.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build Linux Debug)

src/Adapter/MSTest.TestAdapter/Discovery/AssemblyEnumerator.cs#L422

src/Adapter/MSTest.TestAdapter/Discovery/AssemblyEnumerator.cs(422,1): error SA1028: (NETCORE_ENGINEERING_TELEMETRY=Build) Code should not contain trailing whitespace (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1028.md)

Check failure on line 422 in src/Adapter/MSTest.TestAdapter/Discovery/AssemblyEnumerator.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build Linux Debug)

src/Adapter/MSTest.TestAdapter/Discovery/AssemblyEnumerator.cs#L422

src/Adapter/MSTest.TestAdapter/Discovery/AssemblyEnumerator.cs(422,1): error IDE0055: (NETCORE_ENGINEERING_TELEMETRY=Build) Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 422 in src/Adapter/MSTest.TestAdapter/Discovery/AssemblyEnumerator.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build Linux Release)

src/Adapter/MSTest.TestAdapter/Discovery/AssemblyEnumerator.cs#L422

src/Adapter/MSTest.TestAdapter/Discovery/AssemblyEnumerator.cs(422,1): error IDE0055: (NETCORE_ENGINEERING_TELEMETRY=Build) Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 422 in src/Adapter/MSTest.TestAdapter/Discovery/AssemblyEnumerator.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build Linux Release)

src/Adapter/MSTest.TestAdapter/Discovery/AssemblyEnumerator.cs#L422

src/Adapter/MSTest.TestAdapter/Discovery/AssemblyEnumerator.cs(422,1): error SA1028: (NETCORE_ENGINEERING_TELEMETRY=Build) Code should not contain trailing whitespace (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1028.md)

Check failure on line 422 in src/Adapter/MSTest.TestAdapter/Discovery/AssemblyEnumerator.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build Linux Release)

src/Adapter/MSTest.TestAdapter/Discovery/AssemblyEnumerator.cs#L422

src/Adapter/MSTest.TestAdapter/Discovery/AssemblyEnumerator.cs(422,1): error IDE0055: (NETCORE_ENGINEERING_TELEMETRY=Build) Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 422 in src/Adapter/MSTest.TestAdapter/Discovery/AssemblyEnumerator.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build Linux Release)

src/Adapter/MSTest.TestAdapter/Discovery/AssemblyEnumerator.cs#L422

src/Adapter/MSTest.TestAdapter/Discovery/AssemblyEnumerator.cs(422,1): error SA1028: (NETCORE_ENGINEERING_TELEMETRY=Build) Code should not contain trailing whitespace (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1028.md)

Check failure on line 422 in src/Adapter/MSTest.TestAdapter/Discovery/AssemblyEnumerator.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build Linux Release)

src/Adapter/MSTest.TestAdapter/Discovery/AssemblyEnumerator.cs#L422

src/Adapter/MSTest.TestAdapter/Discovery/AssemblyEnumerator.cs(422,1): error IDE0055: (NETCORE_ENGINEERING_TELEMETRY=Build) Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 422 in src/Adapter/MSTest.TestAdapter/Discovery/AssemblyEnumerator.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx

src/Adapter/MSTest.TestAdapter/Discovery/AssemblyEnumerator.cs#L422

src/Adapter/MSTest.TestAdapter/Discovery/AssemblyEnumerator.cs(422,1): error IDE0055: (NETCORE_ENGINEERING_TELEMETRY=Build) Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 422 in src/Adapter/MSTest.TestAdapter/Discovery/AssemblyEnumerator.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx

src/Adapter/MSTest.TestAdapter/Discovery/AssemblyEnumerator.cs#L422

src/Adapter/MSTest.TestAdapter/Discovery/AssemblyEnumerator.cs(422,1): error SA1028: (NETCORE_ENGINEERING_TELEMETRY=Build) Code should not contain trailing whitespace (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1028.md)

Check failure on line 422 in src/Adapter/MSTest.TestAdapter/Discovery/AssemblyEnumerator.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx

src/Adapter/MSTest.TestAdapter/Discovery/AssemblyEnumerator.cs#L422

src/Adapter/MSTest.TestAdapter/Discovery/AssemblyEnumerator.cs(422,1): error IDE0055: (NETCORE_ENGINEERING_TELEMETRY=Build) Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 422 in src/Adapter/MSTest.TestAdapter/Discovery/AssemblyEnumerator.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx

src/Adapter/MSTest.TestAdapter/Discovery/AssemblyEnumerator.cs#L422

src/Adapter/MSTest.TestAdapter/Discovery/AssemblyEnumerator.cs(422,1): error SA1028: (NETCORE_ENGINEERING_TELEMETRY=Build) Code should not contain trailing whitespace (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1028.md)
tests.Add(discoveredTest);
continue;
}
}
catch (ArgumentException) when (MSTestSettings.CurrentSettings.ConsiderEmptyDataSourceAsInconclusive)
{
UnitTestElement discoveredTest = test.Clone();
// Make the test not data driven, because it had no data.
discoveredTest.TestMethod.DataType = DynamicDataType.None;
discoveredTest.DisplayName = dataSource.GetDisplayName(methodInfo, null) ?? discoveredTest.DisplayName;

tests.Add(discoveredTest);
continue;
throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, FrameworkMessages.DynamicDataIEnumerableEmpty, "GetData", dataSource.GetType().Name));
}

var testDisplayNameFirstSeen = new Dictionary<string, int>();
Expand Down

0 comments on commit c3819e2

Please sign in to comment.