未验证 提交 fd965398 编写于 作者: S Sam Harwell 提交者: GitHub

Merge pull request #31142 from sharwell/formatting-analyzer

Enable FormattingAnalyzer
......@@ -30,6 +30,7 @@
<RoslynDiagnosticsNugetPackageVersion>2.6.2-beta2</RoslynDiagnosticsNugetPackageVersion>
<CodeStyleLayerCodeAnalysisVersion>2.8.2</CodeStyleLayerCodeAnalysisVersion>
<MicrosoftCodeAnalysisTestingVersion>1.0.0-beta1-63310-01</MicrosoftCodeAnalysisTestingVersion>
<CodeStyleAnalyzerVersion>2.11.0-beta2-63603-03</CodeStyleAnalyzerVersion>
<BasicUndoVersion>0.9.3</BasicUndoVersion>
<BenchmarkDotNetVersion>0.11.1</BenchmarkDotNetVersion>
......@@ -47,9 +48,11 @@
<MicrosoftCodeAnalysisAnalyzersVersion>$(RoslynDiagnosticsNugetPackageVersion)</MicrosoftCodeAnalysisAnalyzersVersion>
<MicrosoftCodeAnalysisBuildTasksVersion>2.0.0-rc2-61102-09</MicrosoftCodeAnalysisBuildTasksVersion>
<MicrosoftCodeAnalysisCSharpCodeFixTestingXUnitVersion>$(MicrosoftCodeAnalysisTestingVersion)</MicrosoftCodeAnalysisCSharpCodeFixTestingXUnitVersion>
<MicrosoftCodeAnalysisCSharpCodeStyleVersion>$(CodeStyleAnalyzerVersion)</MicrosoftCodeAnalysisCSharpCodeStyleVersion>
<MicrosoftCodeAnalysisElfieVersion>0.10.6</MicrosoftCodeAnalysisElfieVersion>
<MicrosoftCodeAnalysisTestResourcesProprietaryVersion>2.0.14</MicrosoftCodeAnalysisTestResourcesProprietaryVersion>
<MicrosoftCodeAnalysisVisualBasicCodeFixTestingXUnitVersion>$(MicrosoftCodeAnalysisTestingVersion)</MicrosoftCodeAnalysisVisualBasicCodeFixTestingXUnitVersion>
<MicrosoftCodeAnalysisVisualBasicCodeStyleVersion>$(CodeStyleAnalyzerVersion)</MicrosoftCodeAnalysisVisualBasicCodeStyleVersion>
<MicrosoftCodeQualityAnalyzersVersion>$(RoslynDiagnosticsNugetPackageVersion)</MicrosoftCodeQualityAnalyzersVersion>
<SystemCompositionVersion>1.0.31</SystemCompositionVersion>
<MicrosoftCSharpVersion>4.3.0</MicrosoftCSharpVersion>
......
......@@ -413,7 +413,7 @@ function MSBuild() {
$cmdArgs = "$($buildTool.Command) /m /nologo /clp:Summary /v:$verbosity /nr:$nodeReuse"
if ($warnAsError) {
$cmdArgs += " /warnaserror /p:TreatWarningsAsErrors=true"
$cmdArgs += " /p:TreatWarningsAsErrors=true"
}
foreach ($arg in $args) {
......
......@@ -69,6 +69,9 @@
<Rule Id="CA5350" Action="None" /> <!-- in some cases we must use legacy cryptographic hashes, so disable for now -->
<Rule Id="CA5351" Action="None" /> <!-- in some cases we must use legacy cryptographic hashes, so disable for now -->
</Rules>
<Rules AnalyzerId="Microsoft.CodeAnalysis.CodeStyle" RuleNamespace="Microsoft.CodeAnalysis.CodeStyle">
<Rule Id="IDE0055" Action="Warning" />
</Rules>
<Rules AnalyzerId="Microsoft.CodeAnalysis.Analyzers" RuleNamespace="Microsoft.CodeAnalysis.Analyzers">
<Rule Id="RS1001" Action="None" />
<Rule Id="RS1002" Action="None" />
......
......@@ -224,4 +224,18 @@
<None Include="$(MSBuildThisFileDirectory)\..\..\src\Setup\PowerShell\install.ps1" PackagePath="tools\install.ps1" Visible="false" Pack="true"/>
<None Include="$(MSBuildThisFileDirectory)\..\..\src\Setup\PowerShell\uninstall.ps1" PackagePath="tools\uninstall.ps1" Visible="false" Pack="true"/>
</ItemGroup>
<!--
Ensure TargetFrameworkMonikerAssemblyAttributeText is treated as auto-generated
-->
<Target Name="TreatTargetFrameworkMonikerAssemblyAttributeTextAsGenerated"
AfterTargets="_SetTargetFrameworkMonikerAttribute"
Condition="'$(Language)' == 'VB'">
<PropertyGroup>
<TargetFrameworkMonikerAssemblyAttributeText>
' &lt;autogenerated/&gt;
$(TargetFrameworkMonikerAssemblyAttributeText)
</TargetFrameworkMonikerAssemblyAttributeText>
</PropertyGroup>
</Target>
</Project>
......@@ -29,6 +29,7 @@
<RoslynPortableTargetFrameworks>net472;netcoreapp2.1</RoslynPortableTargetFrameworks>
<RoslynPortableRuntimeIdentifiers>win;win-x64;linux-x64;osx-x64</RoslynPortableRuntimeIdentifiers>
<RoslynEnforceCodeStyle Condition="'$(ContinuousIntegrationBuild)' != 'true'">true</RoslynEnforceCodeStyle>
<UseSharedCompilation>true</UseSharedCompilation>
<Features>strict, IOperation</Features>
......@@ -138,6 +139,26 @@
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="$(MicrosoftVisualStudioThreadingAnalyzersVersion)" PrivateAssets="all" />
</ItemGroup>
<!-- Language-specific analyzer packages -->
<Choose>
<When Condition="'$(Language)' == 'VB' and '$(RoslynEnforceCodeStyle)' == 'true'">
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic.CodeStyle" Version="$(MicrosoftCodeAnalysisVisualBasicCodeStyleVersion)" PrivateAssets="all" />
</ItemGroup>
</When>
<When Condition="'$(Language)' == 'C#' and '$(RoslynEnforceCodeStyle)' == 'true'">
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeStyle" Version="$(MicrosoftCodeAnalysisCSharpCodeStyleVersion)" PrivateAssets="all" />
</ItemGroup>
</When>
</Choose>
<PropertyGroup>
<!-- Don't treat FormattingAnalyzer as an error, even when TreatWarningsAsErrors is specified. -->
<WarningsNotAsErrors>$(WarningsNotAsErrors);IDE0055</WarningsNotAsErrors>
</PropertyGroup>
<!--
Language specifc settings
-->
......
......@@ -34,7 +34,7 @@ try {
Push-Location $RepoRoot
Write-Host "Building Roslyn"
Exec-Block { & (Join-Path $PSScriptRoot "build.ps1") -restore -build -ci:$ci -configuration:$configuration -pack -binaryLog -useGlobalNuGetCache:$false }
Exec-Block { & (Join-Path $PSScriptRoot "build.ps1") -restore -build -ci:$ci -configuration:$configuration -pack -binaryLog -useGlobalNuGetCache:$false -properties "/p:RoslynEnforceCodeStyle=true"}
# Verify the state of our various build artifacts
......
......@@ -8,6 +8,7 @@
<RootNamespace>Microsoft.CodeAnalysis.CSharp</RootNamespace>
<TargetFramework>netstandard1.3</TargetFramework>
<DefineConstants>$(DefineConstants),CODE_STYLE</DefineConstants>
<PackageId>Microsoft.CodeAnalysis.CSharp.CodeStyle.NewNameSinceWeReferenceTheAnalyzersAndNuGetCannotFigureItOut</PackageId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="$(MicrosoftCodeAnalysisCSharpFixedVersion)" />
......
......@@ -8,6 +8,7 @@
<TargetFramework>netstandard1.3</TargetFramework>
<RootNamespace></RootNamespace>
<DefineConstants>$(DefineConstants),CODE_STYLE</DefineConstants>
<PackageId>Microsoft.CodeAnalysis.VisualBasic.CodeStyle.NewNameSinceWeReferenceTheAnalyzersAndNuGetCannotFigureItOut</PackageId>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\..\..\Workspaces\VisualBasic\Portable\Extensions\SyntaxTokenExtensions_SharedWithCodeStyle.vb" Link="Formatting\SyntaxTokenExtensions_SharedWithCodeStyle.vb" />
......
......@@ -1214,7 +1214,7 @@ public class C
}
";
var compilation = CreateCompilationWithMscorlib40(source, options: TestOptions.UnsafeReleaseDll);
CompileAndVerify(compilation, verify: Verification.Passes,symbolValidator: module =>
CompileAndVerify(compilation, verify: Verification.Passes, symbolValidator: module =>
{
ValidateDeclSecurity(module, new DeclSecurityEntry
{
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if !NET472
#pragma warning disable IDE0055 // Fix formatting
#endif
#if NET472
using Microsoft.Cci;
......
......@@ -132,16 +132,14 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
Public Sub MarkSymbolAsReferenced(symbol As Symbol, allSymbols As ConcurrentSet(Of Symbol))
#If Not Debug Then
' In RELEASE don't add anything if the collection is sealed
If _sealed = 0 Then
If _sealed <> 0 Then
Return
End If
#End If
Debug.Assert(symbol.IsDefinition)
Debug.Assert(symbol.IsEmbedded)
AddReferencedSymbolWithDependents(symbol, allSymbols)
#If Not Debug Then
End If
#End If
End Sub
Public Sub MarkSymbolAsReferenced(symbol As Symbol)
......
......@@ -1714,10 +1714,10 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
End If
Dim added As Boolean = s_SymbolsBuildingMembersAndInitializers.Add(Me)
Debug.Assert(added)
Try
#End If
Try
' Get type members
Dim typeMembers = GetTypeMembersDictionary()
......@@ -1738,14 +1738,14 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
membersAndInitializers.Members(name) = nontypeSymbols.Concat(StaticCast(Of Symbol).From(typeSymbols))
End If
Next
#If DEBUG Then
Finally
#If DEBUG Then
If added Then
s_SymbolsBuildingMembersAndInitializers.Remove(Me)
End If
End Try
#End If
End Try
Return membersAndInitializers
End Function
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册