Skip to content

Commit

Permalink
Bump Roslyn to 4.6.0 (#1248)
Browse files Browse the repository at this point in the history
  • Loading branch information
josefpihrt authored Nov 18, 2023
1 parent 7053dd2 commit 1320358
Show file tree
Hide file tree
Showing 12 changed files with 75 additions and 17 deletions.
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -205,4 +205,5 @@ dotnet_diagnostic.RS1026.severity = none

dotnet_diagnostic.CA1806.severity = none
dotnet_diagnostic.CA1826.severity = none
dotnet_diagnostic.CA1861.severity = none
dotnet_diagnostic.CA2231.severity = none
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- Bump Roslyn to 4.6.0 ([PR](https://github.com/dotnet/roslynator/pull/1248)).

## [4.6.2] - 2023-11-10

### Added
Expand Down
8 changes: 6 additions & 2 deletions src/CSharp/CSharp/CSharpUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private static bool IsNamespace(

private static bool IsNamespace(
INamespaceSymbol namespaceSymbol,
NameSyntax name,
NameSyntax? name,
SemanticModel semanticModel,
CancellationToken cancellationToken)
{
Expand Down Expand Up @@ -157,7 +157,7 @@ public static bool IsStaticClassInScope(
{
if (usingDirective.StaticKeyword.IsKind(SyntaxKind.StaticKeyword))
{
NameSyntax name = usingDirective.Name;
NameSyntax? name = usingDirective.Name;

if (name is not null
&& SymbolEqualityComparer.Default.Equals(staticClassSymbol, semanticModel.GetSymbol(name, cancellationToken)))
Expand Down Expand Up @@ -647,6 +647,10 @@ public static SeparatedSyntaxList<ParameterSyntax> GetParameters(SyntaxNode decl
case SyntaxKind.RecordDeclaration:
case SyntaxKind.RecordStructDeclaration:
return ((RecordDeclarationSyntax)declaration).ParameterList;
case SyntaxKind.ClassDeclaration:
case SyntaxKind.StructDeclaration:
case SyntaxKind.InterfaceDeclaration:
return ((TypeDeclarationSyntax)declaration).ParameterList;
default:
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion src/CSharp/CSharp/Extensions/SyntaxExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4213,7 +4213,7 @@ public static bool IsVoid(this TypeSyntax type)
#region UsingDirectiveSyntax
internal static IdentifierNameSyntax? GetRootNamespace(this UsingDirectiveSyntax usingDirective)
{
NameSyntax name = usingDirective.Name;
NameSyntax? name = usingDirective.Name;

if (name is AliasQualifiedNameSyntax aliasQualifiedName)
name = aliasQualifiedName.Name;
Expand Down
2 changes: 1 addition & 1 deletion src/CSharp/CSharp/MethodChain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public bool MoveNext()
return null;
}

private static SyntaxNode? GetPreviousSibling(SyntaxNode node)
private static ExpressionSyntax? GetPreviousSibling(SyntaxNode node)
{
SyntaxNode? parent = node.Parent;

Expand Down
50 changes: 47 additions & 3 deletions src/CSharp/CSharp/SyntaxWalkers/CSharpSyntaxNodeWalker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,17 @@ public override void VisitClassDeclaration(ClassDeclarationSyntax node)
return;
}

ParameterListSyntax parameterList = node.ParameterList;
if (parameterList != null)
{
VisitParameterList(parameterList);
}

if (!ShouldVisit)
{
return;
}

BaseListSyntax baseList = node.BaseList;
if (baseList != null)
{
Expand Down Expand Up @@ -2291,6 +2302,17 @@ public override void VisitInterfaceDeclaration(InterfaceDeclarationSyntax node)
return;
}

ParameterListSyntax parameterList = node.ParameterList;
if (parameterList != null)
{
VisitParameterList(parameterList);
}

if (!ShouldVisit)
{
return;
}

BaseListSyntax baseList = node.BaseList;
if (baseList != null)
{
Expand Down Expand Up @@ -3974,6 +3996,17 @@ public override void VisitStructDeclaration(StructDeclarationSyntax node)
return;
}

ParameterListSyntax parameterList = node.ParameterList;
if (parameterList != null)
{
VisitParameterList(parameterList);
}

if (!ShouldVisit)
{
return;
}

BaseListSyntax baseList = node.BaseList;
if (baseList != null)
{
Expand Down Expand Up @@ -4409,6 +4442,17 @@ public override void VisitUsingDirective(UsingDirectiveSyntax node)
return;
}

NameSyntax name = node.Name;
if (name != null)
{
VisitType(name);
}

if (!ShouldVisit)
{
return;
}

NameEqualsSyntax alias = node.Alias;
if (alias != null)
{
Expand All @@ -4420,10 +4464,10 @@ public override void VisitUsingDirective(UsingDirectiveSyntax node)
return;
}

NameSyntax name = node.Name;
if (name != null)
TypeSyntax namespaceOrType = node.NamespaceOrType;
if (namespaceOrType != null)
{
VisitType(name);
VisitType(namespaceOrType);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ private static SyntaxNode InsertStatements(
return ((LocalFunctionStatementSyntax)node).WithBody(newBody);
}

private static SyntaxNode GetBodyOrExpressionBody(SyntaxNode node)
private static CSharpSyntaxNode GetBodyOrExpressionBody(SyntaxNode node)
{
if (node is MethodDeclarationSyntax methodDeclaration)
return methodDeclaration.BodyOrExpressionBody();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context)
}
}

private CodeAction CreateCodeActionForIfElse(Document document, Diagnostic diagnostic, SyntaxNode node)
private static CodeAction CreateCodeActionForIfElse(Document document, Diagnostic diagnostic, SyntaxNode node)
{
switch (node?.Kind())
{
Expand Down
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<PropertyGroup>
<Version Condition="'$(Version)' == ''">1.0.0</Version>
<RoslynatorRoslynVersion>4.4.0</RoslynatorRoslynVersion>
<RoslynatorRoslynVersion>4.6.0</RoslynatorRoslynVersion>
<RoslynatorRoslynAnalyzersVersion>3.3.4</RoslynatorRoslynAnalyzersVersion>
<RoslynatorCliRoslynVersion>4.7.0</RoslynatorCliRoslynVersion>
<RoslynatorTestingRoslynVersion>4.7.0</RoslynatorTestingRoslynVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,14 +285,14 @@ private static SyntaxList<SwitchLabelSyntax> CreateSwitchLabels(IfStatementSynta
throw new InvalidOperationException();
}
}
}

private static SwitchLabelSyntax CreateCaseSwitchLabel(ExpressionSyntax expression)
{
if (expression.IsKind(SyntaxKind.DefaultLiteralExpression))
expression = NullLiteralExpression().WithTriviaFrom(expression);
static SwitchLabelSyntax CreateCaseSwitchLabel(ExpressionSyntax expression)
{
if (expression.IsKind(SyntaxKind.DefaultLiteralExpression))
expression = NullLiteralExpression().WithTriviaFrom(expression);

return CaseSwitchLabel(expression);
return CaseSwitchLabel(expression);
}
}

private static SyntaxList<StatementSyntax> AddBreakStatementIfNecessary(StatementSyntax statement)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ private static ExpressionSyntax AddToStringInvocation(
}
}

private static ExpressionSyntax GetExpression(InterpolatedStringTextSyntax interpolatedStringText, bool isVerbatim)
private static LiteralExpressionSyntax GetExpression(InterpolatedStringTextSyntax interpolatedStringText, bool isVerbatim)
{
SyntaxToken token = interpolatedStringText.TextToken;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@ protected virtual bool ShouldVisit(IPropertySymbol propertySymbol)
case "Modifiers":
case "Keyword":
case "Identifier":
case "ParameterList":
case "TypeParameterList":
case "BaseList":
case "ConstraintClauses":
Expand Down Expand Up @@ -1407,6 +1408,7 @@ protected virtual bool ShouldVisit(IPropertySymbol propertySymbol)
case "Modifiers":
case "Keyword":
case "Identifier":
case "ParameterList":
case "TypeParameterList":
case "BaseList":
case "ConstraintClauses":
Expand Down Expand Up @@ -2348,6 +2350,7 @@ protected virtual bool ShouldVisit(IPropertySymbol propertySymbol)
case "Modifiers":
case "Keyword":
case "Identifier":
case "ParameterList":
case "TypeParameterList":
case "BaseList":
case "ConstraintClauses":
Expand Down Expand Up @@ -2609,8 +2612,10 @@ protected virtual bool ShouldVisit(IPropertySymbol propertySymbol)
case "GlobalKeyword":
case "UsingKeyword":
case "StaticKeyword":
case "UnsafeKeyword":
case "Alias":
case "Name":
case "NamespaceOrType":
case "SemicolonToken":
return true;
default:
Expand Down

0 comments on commit 1320358

Please sign in to comment.