Skip to content

Commit 0685f19

Browse files
authored
Merge pull request #3700 from sharwell/update-deps
Update dependencies
2 parents d1c94ed + b00056d commit 0685f19

17 files changed

Lines changed: 1716 additions & 22 deletions

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ OpenCover.Symbols/
1414
.nuget/NuGet.exe
1515
build/nuget/
1616
*.log
17-
StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp/
1817

1918
# Visual Studio performance tools
2019
*.psess

StyleCop.Analyzers/Directory.Build.props

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@
4040
<NoWarn>$(NoWarn),1573,1591,1712</NoWarn>
4141
</PropertyGroup>
4242

43+
<PropertyGroup>
44+
<SharedMicrosoftCodeAnalysisAnalyzersVersion>3.11.0-beta1.23472.1</SharedMicrosoftCodeAnalysisAnalyzersVersion>
45+
</PropertyGroup>
46+
4347
<ItemGroup>
4448
<PackageReference Include="Nerdbank.GitVersioning" Version="2.2.13" PrivateAssets="all" />
4549
</ItemGroup>
@@ -48,12 +52,12 @@
4852
<PackageReference Include="AsyncUsageAnalyzers" Version="1.0.0-alpha003" PrivateAssets="all" />
4953
<PackageReference Include="DotNetAnalyzers.DocumentationAnalyzers" Version="1.0.0-beta.46" PrivateAssets="all" />
5054
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.435" PrivateAssets="all" />
51-
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.5-beta1.23223.2" PrivateAssets="all" />
55+
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="$(SharedMicrosoftCodeAnalysisAnalyzersVersion)" PrivateAssets="all" />
5256
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeStyle" Version="4.0.1" PrivateAssets="all" />
5357
</ItemGroup>
5458

5559
<ItemGroup>
56-
<PackageReference Include="Microsoft.CodeAnalysis.ResxSourceGenerator" Version="3.3.5-beta1.23223.2" PrivateAssets="all" />
60+
<PackageReference Include="Microsoft.CodeAnalysis.ResxSourceGenerator" Version="$(SharedMicrosoftCodeAnalysisAnalyzersVersion)" PrivateAssets="all" />
5761
</ItemGroup>
5862

5963
<!-- C# Compiler -->
@@ -63,7 +67,7 @@
6367

6468
<!-- Public API -->
6569
<ItemGroup>
66-
<PackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="2.9.7" PrivateAssets="all" />
70+
<PackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="$(SharedMicrosoftCodeAnalysisAnalyzersVersion)" PrivateAssets="all" />
6771
</ItemGroup>
6872

6973
<ItemGroup>

StyleCop.Analyzers/StyleCop.Analyzers.CodeGeneration/OperationLightupGenerator.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,7 @@ public DocumentData(XDocument document)
921921
continue;
922922
}
923923

924-
if (!operationKinds.TryGetValue(node.Attribute("Name").Value, out var kinds))
924+
if (!operationKinds.TryGetValue(node.RequiredAttribute("Name").Value, out var kinds))
925925
{
926926
kinds = ImmutableArray<(string name, int value, string? extraDescription)>.Empty;
927927
}
@@ -937,7 +937,7 @@ public DocumentData(XDocument document)
937937
continue;
938938
}
939939

940-
if (!operationKinds.TryGetValue(node.Attribute("Name").Value, out var kinds))
940+
if (!operationKinds.TryGetValue(node.RequiredAttribute("Name").Value, out var kinds))
941941
{
942942
kinds = ImmutableArray<(string name, int value, string? extraDescription)>.Empty;
943943
}
@@ -987,11 +987,11 @@ public DocumentData(XDocument document)
987987
continue;
988988
}
989989

990-
int parsedValue = ParsePrefixHexValue(entry.Attribute("Value").Value);
991-
nodeBuilder.Add((entry.Attribute("Name").Value, parsedValue, entry.Attribute("ExtraDescription")?.Value));
990+
int parsedValue = ParsePrefixHexValue(entry.RequiredAttribute("Value").Value);
991+
nodeBuilder.Add((entry.RequiredAttribute("Name").Value, parsedValue, entry.Attribute("ExtraDescription")?.Value));
992992
}
993993

994-
builder.Add(node.Attribute("Name").Value, nodeBuilder.ToImmutable());
994+
builder.Add(node.RequiredAttribute("Name").Value, nodeBuilder.ToImmutable());
995995
continue;
996996
}
997997
}
@@ -1008,7 +1008,7 @@ public DocumentData(XDocument document)
10081008
operationKind++;
10091009
}
10101010

1011-
var nodeName = node.Attribute("Name").Value;
1011+
var nodeName = node.RequiredAttribute("Name").Value;
10121012
var kindName = nodeName.Substring("I".Length, nodeName.Length - "I".Length - "Operation".Length);
10131013
builder.Add(nodeName, ImmutableArray.Create((kindName, operationKind, (string?)null)));
10141014
}
@@ -1021,12 +1021,12 @@ private static ImmutableHashSet<int> GetSkippedOperationKinds(XDocument document
10211021
var builder = ImmutableHashSet.CreateBuilder<int>();
10221022
foreach (var skippedKind in document.XPathSelectElements("/Tree/UnusedOperationKinds/Entry"))
10231023
{
1024-
builder.Add(ParsePrefixHexValue(skippedKind.Attribute("Value").Value));
1024+
builder.Add(ParsePrefixHexValue(skippedKind.RequiredAttribute("Value").Value));
10251025
}
10261026

10271027
foreach (var explicitKind in document.XPathSelectElements("/Tree/*/OperationKind/Entry"))
10281028
{
1029-
builder.Add(ParsePrefixHexValue(explicitKind.Attribute("Value").Value));
1029+
builder.Add(ParsePrefixHexValue(explicitKind.RequiredAttribute("Value").Value));
10301030
}
10311031

10321032
return builder.ToImmutable();
@@ -1052,7 +1052,7 @@ public InterfaceData(DocumentData documentData, XElement node, ImmutableArray<(s
10521052
this.documentData = documentData;
10531053

10541054
this.OperationKinds = operationKinds;
1055-
this.InterfaceName = node.Attribute("Name").Value;
1055+
this.InterfaceName = node.RequiredAttribute("Name").Value;
10561056

10571057
if (node.Attribute("Namespace") is { } namespaceNode)
10581058
{
@@ -1127,9 +1127,9 @@ private sealed class PropertyData
11271127
{
11281128
public PropertyData(XElement node)
11291129
{
1130-
this.Name = node.Attribute("Name").Value;
1130+
this.Name = node.RequiredAttribute("Name").Value;
11311131
this.AccessorName = this.Name + "Accessor";
1132-
this.Type = node.Attribute("Type").Value;
1132+
this.Type = node.RequiredAttribute("Type").Value;
11331133

11341134
this.IsNew = node.Attribute("New")?.Value == "true";
11351135
this.IsPublicProperty = node.Attribute("Internal")?.Value != "true";

StyleCop.Analyzers/StyleCop.Analyzers.CodeGeneration/SyntaxLightupGenerator.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,9 +1254,12 @@ private sealed class SyntaxData
12541254
public SyntaxData(CompilationData compilationData, XDocument document)
12551255
{
12561256
var nodesBuilder = ImmutableArray.CreateBuilder<NodeData>();
1257-
foreach (var element in document.XPathSelectElement("/Tree[@Root='SyntaxNode']").XPathSelectElements("PredefinedNode|AbstractNode|Node"))
1257+
if (document.XPathSelectElement("/Tree[@Root='SyntaxNode']") is { } tree)
12581258
{
1259-
nodesBuilder.Add(new NodeData(compilationData, element));
1259+
foreach (var element in tree.XPathSelectElements("PredefinedNode|AbstractNode|Node"))
1260+
{
1261+
nodesBuilder.Add(new NodeData(compilationData, element));
1262+
}
12601263
}
12611264

12621265
this.Nodes = nodesBuilder.ToImmutable();
@@ -1303,7 +1306,7 @@ public NodeData(CompilationData compilationData, XElement element)
13031306
_ => throw new NotSupportedException($"Unknown element name '{element.Name}'"),
13041307
};
13051308

1306-
this.Name = element.Attribute("Name").Value;
1309+
this.Name = element.RequiredAttribute("Name").Value;
13071310

13081311
this.ExistingType = compilationData.ExistingTypes.GetValueOrDefault($"Microsoft.CodeAnalysis.CSharp.Syntax.{this.Name}")
13091312
?? compilationData.ExistingTypes.GetValueOrDefault($"Microsoft.CodeAnalysis.CSharp.{this.Name}")
@@ -1317,7 +1320,7 @@ public NodeData(CompilationData compilationData, XElement element)
13171320
this.WrapperName = this.Name + "Wrapper";
13181321
}
13191322

1320-
this.BaseName = element.Attribute("Base").Value;
1323+
this.BaseName = element.RequiredAttribute("Base").Value;
13211324
this.Fields = element.XPathSelectElements("descendant::Field").Select(field => new FieldData(this, field)).ToImmutableArray();
13221325
}
13231326

@@ -1347,9 +1350,9 @@ public FieldData(NodeData nodeData, XElement element)
13471350
{
13481351
this.nodeData = nodeData;
13491352

1350-
this.Name = element.Attribute("Name").Value;
1353+
this.Name = element.RequiredAttribute("Name").Value;
13511354

1352-
var type = element.Attribute("Type").Value;
1355+
var type = element.RequiredAttribute("Type").Value;
13531356
this.Type = type switch
13541357
{
13551358
"SyntaxList<SyntaxToken>" => nameof(SyntaxTokenList),
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2+
// Licensed under the MIT License. See LICENSE in the project root for license information.
3+
4+
namespace StyleCop.Analyzers.CodeGeneration
5+
{
6+
using System;
7+
using System.Xml.Linq;
8+
9+
internal static class XElementExtensions
10+
{
11+
public static XAttribute RequiredAttribute(this XElement element, XName name)
12+
=> element.Attribute(name) ?? throw new InvalidOperationException($"Expected attribute '{name}'");
13+
}
14+
}

StyleCop.Analyzers/StyleCop.Analyzers.Internal.ruleset

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@
1313
<Rule Id="RS1001" Action="None" /> <!-- Missing diagnostic analyzer attribute -->
1414
<Rule Id="RS1004" Action="None" /> <!-- Recommend adding language support to diagnostic analyzer -->
1515
<Rule Id="RS1029" Action="None" /> <!-- Do not use reserved diagnostic IDs -->
16+
<Rule Id="RS1038" Action="None" /> <!-- Compiler extensions should be implemented in assemblies with compiler-provided references -->
1617
<Rule Id="RS2008" Action="None" /> <!-- Enable analyzer release tracking -->
1718
</Rules>
19+
<Rules AnalyzerId="Microsoft.CodeAnalysis.PublicApiAnalyzers" RuleNamespace="Microsoft.CodeAnalysis.PublicApiAnalyzers">
20+
<Rule Id="RS0016" Action="None" /> <!-- Add public types and members to the declared API -->
21+
<Rule Id="RS0026" Action="None" /> <!-- Do not add multiple public overloads with optional parameters -->
22+
<Rule Id="RS0037" Action="None" /> <!-- Enable tracking of nullability of reference types in the declared API -->
23+
</Rules>
1824
</RuleSet>

0 commit comments

Comments
 (0)