Skip to content

Commit db9d500

Browse files
committed
Merge remote-tracking branch 'DotNetAnalyzers/master' into fix-3106
2 parents 0b2b098 + e5e203d commit db9d500

1,560 files changed

Lines changed: 7566 additions & 2342 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CONTRIBUTING.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ for issues suitable if you are unfamiliar with roslyn.
77

88
You can also help by filing issues, participating in discussions and doing code review.
99

10+
## Building prerequisites
11+
12+
* Visual Studio 2017 (Community Edition or higher) is required for building this repository.
13+
* The version of the [.NET Core SDK](https://dotnet.microsoft.com/download/dotnet-core) as specified in the global.json file at the root of this repo.
14+
Use the init script at the root of the repo to conveniently acquire and install the right version.
15+
1016
## Implementing a diagnostic
1117

1218
1. To start working on a diagnostic, add a comment to the issue indicating you are working on implementing it.
@@ -23,7 +29,3 @@ You can also help by filing issues, participating in discussions and doing code
2329
2. A new issue was created for implementing tests for the item (e.g. #176).
2430
3. Evidence was given that the feature is currently operational, and the code appears to be a solid starting point
2531
for other contributors to continue the implementation effort.
26-
27-
## Building
28-
29-
Visual Studio 2017 (Community Edition or higher) is required for building this repository.

LICENSE

Lines changed: 21 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,21 @@
1-
Copyright (c) Tunnel Vision Laboratories, LLC. All rights reserved.
2-
3-
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4-
these files except in compliance with the License. You may obtain a copy of the
5-
License at
6-
7-
http://www.apache.org/licenses/LICENSE-2.0
8-
9-
Unless required by applicable law or agreed to in writing, software distributed
10-
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
11-
CONDITIONS OF ANY KIND, either express or implied. See the License for the
12-
specific language governing permissions and limitations under the License.
13-
14-
---
15-
16-
This project uses other open source projects, which are used under the terms
17-
of the following license(s).
18-
19-
.NET Compiler Platform ("Roslyn")
20-
21-
Copyright Microsoft.
22-
23-
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
24-
these files except in compliance with the License. You may obtain a copy of the
25-
License at
26-
27-
http://www.apache.org/licenses/LICENSE-2.0
28-
29-
Unless required by applicable law or agreed to in writing, software distributed
30-
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
31-
CONDITIONS OF ANY KIND, either express or implied. See the License for the
32-
specific language governing permissions and limitations under the License.
33-
34-
Code Cracker
35-
36-
Copyright 2014 Giovanni Bassi and Elemar Jr.
37-
38-
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
39-
these files except in compliance with the License. You may obtain a copy of the
40-
License at
41-
42-
http://www.apache.org/licenses/LICENSE-2.0
43-
44-
Unless required by applicable law or agreed to in writing, software distributed
45-
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
46-
CONDITIONS OF ANY KIND, either express or implied. See the License for the
47-
specific language governing permissions and limitations under the License.
48-
49-
LightJson
50-
51-
Copyright (c) 2017 Marcos López C.
52-
53-
Permission is hereby granted, free of charge, to any person obtaining a copy
54-
of this software and associated documentation files (the "Software"), to deal
55-
in the Software without restriction, including without limitation the rights
56-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
57-
copies of the Software, and to permit persons to whom the Software is
58-
furnished to do so, subject to the following conditions:
59-
60-
The above copyright notice and this permission notice shall be included in
61-
all copies or substantial portions of the Software.
62-
63-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
64-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
65-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
66-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
67-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
68-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
69-
THE SOFTWARE.
1+
MIT License
2+
3+
Copyright (c) Tunnel Vision Laboratories, LLC
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

NuGet.config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
<packageSources>
44
<clear />
55
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
6-
<add key="roslyn" value="https://dotnet.myget.org/F/roslyn/api/v3/index.json" />
7-
<add key="roslyn-analyzers" value="https://dotnet.myget.org/F/roslyn-analyzers/api/v3/index.json" />
6+
<add key="dotnet-tools" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json" />
7+
<add key="dotnet5" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet5/nuget/v3/index.json" />
88

99
<!-- Uncomment this to test unpublished builds from the AppVeyor feed. -->
1010
<!--<add key="appveyor-stylecop" value="https://ci.appveyor.com/nuget/stylecopanalyzers" />-->

StyleCop.Analyzers/Directory.Build.props

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</PropertyGroup>
1111

1212
<PropertyGroup>
13-
<LangVersion>7.2</LangVersion>
13+
<LangVersion>8</LangVersion>
1414
<Features>strict</Features>
1515
</PropertyGroup>
1616

@@ -45,8 +45,9 @@
4545
<ItemGroup>
4646
<PackageReference Include="AsyncUsageAnalyzers" Version="1.0.0-alpha003" PrivateAssets="all" />
4747
<PackageReference Include="DotNetAnalyzers.DocumentationAnalyzers" Version="1.0.0-beta.46" PrivateAssets="all" />
48-
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.66" PrivateAssets="all" />
49-
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeStyle" Version="2.11.0-beta2-63603-03" PrivateAssets="all" />
48+
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.205" PrivateAssets="all" />
49+
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.0" PrivateAssets="all" />
50+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeStyle" Version="3.7.0-6.20427.1" PrivateAssets="all" />
5051
</ItemGroup>
5152

5253
<!-- Public API -->

StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/FileHeaderCodeFixProvider.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2-
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
2+
// Licensed under the MIT License. See LICENSE in the project root for license information.
33

44
namespace StyleCop.Analyzers.DocumentationRules
55
{
@@ -66,6 +66,9 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context)
6666
return SpecializedTasks.CompletedTask;
6767
}
6868

69+
private static string GetFileName(Document document)
70+
=> Path.GetFileName(document.FilePath ?? document.Name);
71+
6972
private static async Task<Document> GetTransformedDocumentAsync(Document document, CancellationToken cancellationToken)
7073
{
7174
return document.WithSyntaxRoot(await GetTransformedSyntaxRootAsync(document, cancellationToken).ConfigureAwait(false));
@@ -80,7 +83,7 @@ private static async Task<SyntaxNode> GetTransformedSyntaxRootAsync(Document doc
8083
SyntaxNode newSyntaxRoot;
8184
if (fileHeader.IsMissing)
8285
{
83-
newSyntaxRoot = AddHeader(document, root, document.Name, settings);
86+
newSyntaxRoot = AddHeader(document, root, GetFileName(document), settings);
8487
}
8588
else
8689
{
@@ -144,9 +147,9 @@ private static SyntaxNode ReplaceWellFormedMultiLineCommentHeader(Document docum
144147
// Pad line that used to be next to a /*
145148
triviaStringParts[0] = commentIndentation + interlinePadding + " " + triviaStringParts[0];
146149
StringBuilder sb = StringBuilderPool.Allocate();
147-
string fileName = Path.GetFileName(document.FilePath);
150+
string fileName = GetFileName(document);
148151
var copyrightText = GetCopyrightText(commentIndentation + interlinePadding, settings.DocumentationRules.GetCopyrightText(fileName), newLineText);
149-
var newHeader = WrapInXmlComment(commentIndentation + interlinePadding, copyrightText, document.Name, settings, newLineText);
152+
var newHeader = WrapInXmlComment(commentIndentation + interlinePadding, copyrightText, fileName, settings, newLineText);
150153

151154
sb.Append(commentIndentation);
152155
sb.Append("/*");
@@ -310,7 +313,7 @@ private static SyntaxNode ReplaceHeader(Document document, SyntaxNode root, Styl
310313
string newLineText = document.Project.Solution.Workspace.Options.GetOption(FormattingOptions.NewLine, LanguageNames.CSharp);
311314
var newLineTrivia = SyntaxFactory.EndOfLine(newLineText);
312315

313-
var newHeaderTrivia = CreateNewHeader(leadingSpaces + "//", document.Name, settings, newLineText);
316+
var newHeaderTrivia = CreateNewHeader(leadingSpaces + "//", GetFileName(document), settings, newLineText);
314317
if (!isMalformedHeader && copyrightTriviaIndex.HasValue)
315318
{
316319
// Does the copyright element have leading whitespace? If so remove it.

StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/InheritdocCodeFixProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2-
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
2+
// Licensed under the MIT License. See LICENSE in the project root for license information.
33

44
namespace StyleCop.Analyzers.DocumentationRules
55
{

StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/PropertySummaryDocumentationCodeFixProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2-
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
2+
// Licensed under the MIT License. See LICENSE in the project root for license information.
33

44
namespace StyleCop.Analyzers.DocumentationRules
55
{

StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/SA1600CodeFixProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2-
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
2+
// Licensed under the MIT License. See LICENSE in the project root for license information.
33

44
namespace StyleCop.Analyzers.DocumentationRules
55
{

StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/SA1609SA1610CodeFixProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2-
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
2+
// Licensed under the MIT License. See LICENSE in the project root for license information.
33

44
namespace StyleCop.Analyzers.DocumentationRules
55
{

StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/SA1615SA1616CodeFixProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2-
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
2+
// Licensed under the MIT License. See LICENSE in the project root for license information.
33

44
namespace StyleCop.Analyzers.DocumentationRules
55
{

0 commit comments

Comments
 (0)