Permalink
Browse files

Clean up rulesets (#31554)

  • Loading branch information...
tmat committed Dec 5, 2018
1 parent 5e0c1c5 commit 6a9a2578a285248db835bbb9cf866e64c0134d05
Showing with 47 additions and 165 deletions.
  1. +0 −29 build/Rulesets/AnalyzerProject_BuildRules.ruleset
  2. +0 −9 build/Rulesets/AnalyzerProject_RunCodeAnalysisRules.ruleset
  3. +0 −54 build/Rulesets/Core_RunCodeAnalysisRules.ruleset
  4. +1 −1 build/Rulesets/{NonShippingProject_BuildRules.ruleset → NonShipping.ruleset}
  5. +0 −8 build/Rulesets/NonShippingProject_RunCodeAnalysisRules.ruleset
  6. +0 −8 build/Rulesets/Roslyn_RunCodeAnalysisRules.ruleset
  7. 0 build/Rulesets/{Roslyn_BuildRules.ruleset → Shipping.ruleset}
  8. +0 −25 build/Targets/BeforeCommonTargets.targets
  9. +6 −0 build/Targets/Imports.targets
  10. +3 −0 build/Targets/Settings.props
  11. +7 −0 src/CodeStyle/Directory.Build.targets
  12. +1 −1 src/Compilers/CSharp/CSharpCodeAnalysisRules.ruleset
  13. +1 −1 src/Compilers/Core/CodeAnalysisRules.ruleset
  14. +1 −1 src/Compilers/VisualBasic/BasicCodeAnalysisRules.ruleset
  15. +2 −2 src/EditorFeatures/CSharp/DecompiledSource/CSharpDecompiledSourceService.cs
  16. +1 −1 src/Features/CSharp/Portable/UseIndexOrRangeOperator/CSharpUseRangeOperatorCodeFixProvider.cs
  17. +2 −2 src/Features/Core/Portable/CodeRefactorings/AddAwait/AbstractAddAwaitCodeRefactoringProvider.cs
  18. +2 −2 ...tures/Core/Portable/CodeRefactorings/AddMissingImports/AbstractAddMissingImportsFeatureService.cs
  19. +2 −2 ...eatures/Core/Portable/MoveDeclarationNearReference/AbstractMoveDeclarationNearReferenceService.cs
  20. +2 −3 ...Core/Portable/MoveDeclarationNearReference/MoveDeclarationNearReferenceCodeRefactoringProvider.cs
  21. +2 −2 src/Features/Core/Portable/NameTupleElement/AbstractNameTupleElementCodeRefactoringProvider.cs
  22. +3 −3 src/Features/Core/Portable/PullMemberUp/QuickAction/AbstractMemberPullerWithQuickAction.cs
  23. +1 −1 src/Tools/dotnet-format/MSBuild/MSBuildWorkspaceFinder.cs
  24. +2 −2 src/Tools/dotnet-format/Program.cs
  25. +1 −1 src/VisualStudio/Core/Def/Experimentation/VisualStudioExperimentationService.cs
  26. +1 −1 src/VisualStudio/Core/Def/Implementation/CodeLens/RemoteCodeLensReferencesService.cs
  27. +1 −1 src/VisualStudio/Core/Def/Implementation/LanguageService/AbstractPackage.cs
  28. +1 −1 src/VisualStudio/Core/Def/Implementation/Venus/ContainedDocument.DocumentServiceProvider.cs
  29. +1 −1 src/VisualStudio/Core/Def/Implementation/Workspace/VisualStudioActiveDocumentTracker.cs
  30. +1 −1 src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/FixAllContext.DiagnosticProvider.cs
  31. +1 −1 src/Workspaces/Core/Portable/CodeGeneration/AbstractCodeGenerationService_FindDeclaration.cs
  32. +1 −1 src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/PropertySymbolReferenceFinder.cs

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<RuleSet Name="Common diagnostic rules for all non-shipping projects" Description="Enables/disable rules specific to all non-shipping projects." ToolsVersion="14.0">
<Include Path=".\Roslyn_BuildRules.ruleset" Action="Default" />
<Include Path=".\Shipping.ruleset" Action="Default" />

<Rules AnalyzerId="Microsoft.CodeQuality.Analyzers" RuleNamespace="Microsoft.CodeQuality.Analyzers">
<!-- For tests, the ConfigureAwait(true) is good enough. Either they are already running on a thread pool

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.
@@ -57,30 +57,5 @@
<IntermediateOutputPath>$(IntermediateOutputPath)$(TargetFramework.ToLowerInvariant())\</IntermediateOutputPath>
<OutputPath Condition="'$(RoslynProjectType)' != 'SourcePackage' and '$(RoslynProjectType)' != 'Custom'">$(OutputPath)$(TargetFramework.ToLowerInvariant())\</OutputPath>
</PropertyGroup>

<!-- If the project hasn't configured a ruleset, set a default ruleset. -->
<Choose>
<When Condition="'$(CodeAnalysisRuleSet)' == ''">
<Choose>
<!-- We have different default rulesets for Build versus Running Code Analysis. -->
<When Condition="'$(RunCodeAnalysis)' == 'true' OR '$(RunCodeAnalysisOnce)' == 'true'">
<PropertyGroup>
<DefaultRulesetSuffix>_RunCodeAnalysisRules</DefaultRulesetSuffix>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<DefaultRulesetSuffix>_BuildRules</DefaultRulesetSuffix>
</PropertyGroup>
</Otherwise>
</Choose>

<PropertyGroup>
<CodeAnalysisRuleSet Condition="'$(CodeAnalysisRuleSet)' == '' AND '$(IsShipping)' != 'true'">$(MSBuildThisFileDirectory)..\Rulesets\NonShippingProject$(DefaultRulesetSuffix).ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSet Condition="'$(CodeAnalysisRuleSet)' == '' AND '$(AnalyzerProject)' == 'true'">$(MSBuildThisFileDirectory)..\Rulesets\AnalyzerProject$(DefaultRulesetSuffix).ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSet Condition="'$(CodeAnalysisRuleSet)' == ''">$(MSBuildThisFileDirectory)..\Rulesets\Roslyn$(DefaultRulesetSuffix).ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
</When>
</Choose>
</Project>

@@ -68,6 +68,12 @@
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
</PropertyGroup>

<!-- Rulesets -->
<PropertyGroup Condition="'$(CodeAnalysisRuleSet)' == ''">
<CodeAnalysisRuleSet Condition="'$(IsShipping)' == 'true'">$(RepoRoot)build\Rulesets\Shipping.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSet Condition="'$(IsShipping)' != 'true'">$(RepoRoot)build\Rulesets\NonShipping.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>

<!--
Some dependencies bring in references to UIAutomationClient and UIAutomationTypes. These conflict with the faster
UIAComWrapper implementation used by the Roslyn integration tests. This target sets the alias for the slower
@@ -41,6 +41,9 @@
<GenerateFullPaths>true</GenerateFullPaths>
<UseRoslynAnalyzers Condition="'$(UseRoslynAnalyzers)' == ''">true</UseRoslynAnalyzers>

<!-- Set to non-existent file to prevent common targets from importing Microsoft.CodeAnalysis.targets -->
<CodeAnalysisTargets>*none*</CodeAnalysisTargets>

<ThirdPartyNoticesFilePath>$(MSBuildThisFileDirectory)..\..\src\NuGet\ThirdPartyNotices.rtf</ThirdPartyNoticesFilePath>
<TargetFrameworkRootPath>$(NuGetPackageRoot)\roslyntools.referenceassemblies\$(RoslynToolsReferenceAssembliesVersion)\tools\framework</TargetFrameworkRootPath>
<IbcOptimizationDataDir>$(NuGetPackageRoot)roslyndependencies.optimizationdata\$(RoslynDependenciesOptimizationDataVersion)\content\OptimizationData\</IbcOptimizationDataDir>
@@ -0,0 +1,7 @@
<Project>
<Import Project="..\..\Directory.Build.targets"/>
<ItemGroup>
<!-- The analyzer does not apply to CodeStyle layer -->
<PackageReference Remove="Roslyn.Diagnostics.Analyzers"/>
</ItemGroup>
</Project>
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<RuleSet Name="Diagnostic rules for the CSharpCodeAnalysis (Portable and Desktop) projects" Description="Enables rules specific to these projects." ToolsVersion="14.0">
<!-- Include default rules -->
<Include Path="..\..\..\build\Rulesets\Roslyn_BuildRules.ruleset" Action="Default" />
<Include Path="..\..\..\build\Rulesets\Shipping.ruleset" Action="Default" />
<Rules AnalyzerId="Roslyn.Diagnostics.Analyzers.CSharp" RuleNamespace="Roslyn.Diagnostics.Analyzers.CSharp">
<Rule Id="RS0013" Action="Warning" />
</Rules>
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<RuleSet Name="Diagnostic rules for the CodeAnalysis (Portable and Desktop) projects" Description="Enables rules specific to these projects." ToolsVersion="14.0">
<!-- Include default rules -->
<Include Path="..\..\..\build\Rulesets\Roslyn_BuildRules.ruleset" Action="Default" />
<Include Path="..\..\..\build\Rulesets\Shipping.ruleset" Action="Default" />
<Rules AnalyzerId="Roslyn.Diagnostics.Analyzers.CSharp" RuleNamespace="Roslyn.Diagnostics.Analyzers.CSharp">
<Rule Id="RS0013" Action="Warning" />
</Rules>
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<RuleSet Name="Diagnostic rules for the BasicCodeAnalysis (Portable and Desktop) projects" Description="Enables rules specific to these projects." ToolsVersion="14.0">
<!-- Include default rules -->
<Include Path="..\..\..\build\Rulesets\Roslyn_BuildRules.ruleset" Action="Default" />
<Include Path="..\..\..\build\Rulesets\Shipping.ruleset" Action="Default" />
<Rules AnalyzerId="Roslyn.Diagnostics.Analyzers.VisualBasic" RuleNamespace="Roslyn.Diagnostics.Analyzers.VisualBasic">
<Rule Id="RS0004" Action="Error" />
</Rules>
@@ -74,11 +74,11 @@ public async Task<Document> AddSourceToAsync(Document document, ISymbol symbol,
// Decompile
document = PerformDecompilation(document, fullName, compilation, assemblyLocation);

document = await AddAssemblyInfoRegionAsync(document, symbol, cancellationToken);
document = await AddAssemblyInfoRegionAsync(document, symbol, cancellationToken).ConfigureAwait(false);

// Convert XML doc comments to regular comments, just like MAS
var docCommentFormattingService = document.GetLanguageService<IDocumentationCommentFormattingService>();
document = await ConvertDocCommentsToRegularCommentsAsync(document, docCommentFormattingService, cancellationToken);
document = await ConvertDocCommentsToRegularCommentsAsync(document, docCommentFormattingService, cancellationToken).ConfigureAwait(false);

var node = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);

@@ -51,7 +51,7 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context)
canReplace: (_1, _2) => true,
(semanticModel, currentRoot, currentInvocation) =>
UpdateInvocation(semanticModel, currentRoot, currentInvocation, cancellationToken),
cancellationToken);
cancellationToken).ConfigureAwait(false);
}

private SyntaxNode UpdateInvocation(
@@ -42,7 +42,7 @@ public sealed override async Task ComputeRefactoringsAsync(CodeRefactoringContex
var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
var token = root.FindTokenOnLeftOfPosition(textSpan.Start);

var model = await document.GetSemanticModelAsync(cancellationToken);
var model = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
var syntaxFacts = document.GetLanguageService<ISyntaxFactsService>();
var awaitable = GetAwaitableExpression(textSpan, token, model, syntaxFacts, cancellationToken);
if (awaitable == null)
@@ -108,7 +108,7 @@ private TExpressionSyntax GetAwaitableExpression(TextSpan textSpan, SyntaxToken
.AddParentheses(syntaxGenerator.AwaitExpression(withoutTrivia))
.WithTriviaFrom(invocation);

return await document.ReplaceNodeAsync(invocation, awaitExpression, cancellationToken);
return await document.ReplaceNodeAsync(invocation, awaitExpression, cancellationToken).ConfigureAwait(false); ;
}

private class MyCodeAction : CodeAction.DocumentChangeAction
@@ -57,7 +57,7 @@ public async Task<Project> AddMissingImportsAsync(Document document, TextSpan te

private async Task<ImmutableArray<Diagnostic>> GetDiagnosticsAsync(Document document, TextSpan textSpan, CancellationToken cancellationToken)
{
var semanticModel = await document.GetSemanticModelAsync(cancellationToken);
var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
if (semanticModel is null)
{
return ImmutableArray<Diagnostic>.Empty;
@@ -150,7 +150,7 @@ private async Task<Document> ApplyFixesAsync(Document document, ImmutableArray<A
var orderedTextInserts = allTextChanges.Where(change => change.Span.IsEmpty)
.OrderBy(change => change.NewText);

var text = await document.GetTextAsync(cancellationToken);
var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
var newText = text.WithChanges(orderedTextInserts);
var newDocument = newProject.GetDocument(document.Id).WithText(newText);

@@ -70,13 +70,13 @@ private async Task<State> ComputeStateAsync(Document document, SyntaxNode node,
public async Task<Document> MoveDeclarationNearReferenceAsync(
Document document, SyntaxNode localDeclarationStatement, CancellationToken cancellationToken)
{
var state = await ComputeStateAsync(document, localDeclarationStatement, cancellationToken);
var state = await ComputeStateAsync(document, localDeclarationStatement, cancellationToken).ConfigureAwait(false);
if (state == null)
{
return document;
}

var root = await document.GetSyntaxRootAsync(cancellationToken);
var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
var editor = new SyntaxEditor(root, document.Project.Solution.Workspace);

var crossesMeaningfulBlock = CrossesMeaningfulBlock(state);
@@ -53,8 +53,7 @@ public override async Task ComputeRefactoringsAsync(CodeRefactoringContext conte
}

var service = document.GetLanguageService<IMoveDeclarationNearReferenceService>();
if (!await service.CanMoveDeclarationNearReferenceAsync(
document, statement, cancellationToken))
if (!await service.CanMoveDeclarationNearReferenceAsync(document, statement, cancellationToken).ConfigureAwait(false))
{
return;
}
@@ -80,7 +79,7 @@ public override async Task ComputeRefactoringsAsync(CodeRefactoringContext conte
var statement = await GetLocalDeclarationStatementAsync(document, span, cancellationToken).ConfigureAwait(false);
var service = document.GetLanguageService<IMoveDeclarationNearReferenceService>();

return await service.MoveDeclarationNearReferenceAsync(document, statement, cancellationToken);
return await service.MoveDeclarationNearReferenceAsync(document, statement, cancellationToken).ConfigureAwait(false);
}

private class MyCodeAction : CodeAction.DocumentChangeAction
@@ -25,7 +25,7 @@ public override async Task ComputeRefactoringsAsync(CodeRefactoringContext conte
var cancellationToken = context.CancellationToken;
var document = context.Document;

var (_, _, elementName) = await TryGetArgumentInfo(document, span, cancellationToken);
var (_, _, elementName) = await TryGetArgumentInfo(document, span, cancellationToken).ConfigureAwait(false);

if (elementName == null)
{
@@ -102,7 +102,7 @@ public override async Task ComputeRefactoringsAsync(CodeRefactoringContext conte

private async Task<Document> AddNamedElementAsync(Document document, TextSpan span, CancellationToken cancellationToken)
{
var (root, argument, elementName) = await TryGetArgumentInfo(document, span, cancellationToken);
var (root, argument, elementName) = await TryGetArgumentInfo(document, span, cancellationToken).ConfigureAwait(false);

var newArgument = WithName(argument, elementName).WithTriviaFrom(argument);
var newRoot = root.ReplaceNode(argument, newArgument);
Oops, something went wrong.

0 comments on commit 6a9a257

Please sign in to comment.