Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more analyzers #1974

Merged
merged 3 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion TestFx.sln
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MSTest.Analyzers.CodeFixes"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MSTest.Analyzers.Package", "src\Analyzers\MSTest.Analyzers.Package\MSTest.Analyzers.Package.csproj", "{DC068986-7549-4B75-8EFC-A9958FD5CF88}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MSTest.Analyzers.Test", "test\UnitTests\MSTest.Analyzers.Test\MSTest.Analyzers.Test.csproj", "{1FF35C23-C128-4C95-B3F8-67B1B4C51E4D}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MSTest.Analyzers.UnitTests", "test\UnitTests\MSTest.Analyzers.UnitTests\MSTest.Analyzers.UnitTests.csproj", "{1FF35C23-C128-4C95-B3F8-67B1B4C51E4D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MSTest.Sdk", "src\Package\MSTest.Sdk\MSTest.Sdk.csproj", "{10930CFD-EDF9-4486-B0A3-49230B5A6798}"
EndProject
Expand Down
4 changes: 3 additions & 1 deletion src/Analyzers/MSTest.Analyzers/AnalyzerReleases.Unshipped.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@

Rule ID | Category | Severity | Notes
--------|----------|----------|-------
MSTEST0001 | Performance | Warning | UseParallelizeAttributeAnalyzer
MSTEST0001 | Performance | Warning | UseParallelizeAttributeAnalyzer, [Documentation](https://github.com/microsoft/testfx/blob/main/docs/analyzers/MSTEST0001.md)
MSTEST0002 | Usage | Warning | TestClassShouldBePublicAnalyzer, [Documentation](https://github.com/microsoft/testfx/blob/main/docs/analyzers/MSTEST0002.md)
MSTEST0003 | Usage | Warning | TestMethodShouldBePublicAnalyzer, [Documentation](https://github.com/microsoft/testfx/blob/main/docs/analyzers/MSTEST0003.md)
1 change: 1 addition & 0 deletions src/Analyzers/MSTest.Analyzers/Helpers/Categories.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ namespace MSTest.Analyzers;
internal static class Categories
{
public const string Performance = nameof(Performance);
public const string Usage = nameof(Usage);
}
2 changes: 2 additions & 0 deletions src/Analyzers/MSTest.Analyzers/Helpers/DiagnosticIds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ namespace MSTest.Analyzers;
internal static class DiagnosticIds
{
public const string UseParallelizedAttributeRuleId = "MSTEST0001";
public const string TestClassShouldBePublicRuleId = "MSTEST0002";
public const string TestMethodShouldBePublicRuleId = "MSTEST0003";
}
4 changes: 3 additions & 1 deletion src/Analyzers/MSTest.Analyzers/Helpers/WellKnownTypeNames.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ namespace MSTest.Analyzers;
// IMPORTANT: Keep this file sorted alphabetically.
internal static class WellKnownTypeNames
{
public const string MicrosoftVisualStudioTestToolsUnitTestingParallelizeAttribute = "Microsoft.VisualStudio.TestTools.UnitTesting.ParallelizeAttribute";
public const string MicrosoftVisualStudioTestToolsUnitTestingDoNotParallelizeAttribute = "Microsoft.VisualStudio.TestTools.UnitTesting.DoNotParallelizeAttribute";
public const string MicrosoftVisualStudioTestToolsUnitTestingParallelizeAttribute = "Microsoft.VisualStudio.TestTools.UnitTesting.ParallelizeAttribute";
public const string MicrosoftVisualStudioTestToolsUnitTestingTestClassAttribute = "Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute";
public const string MicrosoftVisualStudioTestToolsUnitTestingTestMethodAttribute = "Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute";

public const string SystemThreadingTasksTask1 = "System.Threading.Tasks.Task`1";
}
2 changes: 1 addition & 1 deletion src/Analyzers/MSTest.Analyzers/MSTest.Analyzers.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</ItemGroup>

<ItemGroup>
<InternalsVisibleTo Include="MSTest.Analyzers.Test" Key="$(VsPublicKey)" />
<InternalsVisibleTo Include="MSTest.Analyzers.UnitTests" Key="$(VsPublicKey)" />
</ItemGroup>

<ItemGroup>
Expand Down
54 changes: 54 additions & 0 deletions src/Analyzers/MSTest.Analyzers/Resources.Designer.cs

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

18 changes: 18 additions & 0 deletions src/Analyzers/MSTest.Analyzers/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,24 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="TestClassShouldBePublicDescription" xml:space="preserve">
<value>MSTest only considers public classes marked with the '[TestClass]' attribute as test classes.</value>
</data>
<data name="TestClassShouldBePublicMessageFormat" xml:space="preserve">
<value>Test class '{0}' should be public</value>
</data>
<data name="TestClassShouldBePublicTitle" xml:space="preserve">
<value>Classes marked with '[TestClass]' should be public</value>
</data>
<data name="TestMethodShouldBePublicDescription" xml:space="preserve">
<value>MSTest only considers public methods marked with the '[TestMethod]' attribute as test methods.</value>
</data>
<data name="TestMethodShouldBePublicMessageFormat" xml:space="preserve">
<value>Test method '{0}' should be public</value>
</data>
<data name="TestMethodShouldBePublicTitle" xml:space="preserve">
<value>Methods marked with '[TestMethod]' should be public</value>
</data>
<data name="UseParallelizeAttributeAnalyzerDescription" xml:space="preserve">
<value>By default, MSTest runs tests sequentially which can lead to severe performance limitations. It is recommended to enable assembly attribute 'Parallelize' or if the assembly is known to not be parallelizable, to use explicitly the assembly level attribute 'DoNotParallelize'.</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ dotnet_diagnostic.SA1214.severity = none
dotnet_diagnostic.SA1311.severity = none
dotnet_diagnostic.SA1314.severity = none
dotnet_diagnostic.SA1405.severity = none
dotnet_diagnostic.SA1413.severity = none
dotnet_diagnostic.SA1502.severity = none
dotnet_diagnostic.SA1512.severity = none
dotnet_diagnostic.SA1516.severity = none
Expand Down
Loading
Loading