Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -587,4 +587,4 @@
<data name="Convert_all_extension_methods_in_0_to_extension" xml:space="preserve">
<value>Convert all extension methods in '{0}' to extension</value>
</data>
</root>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,7 @@ internal override bool IsDeclarationWithInitializer(SyntaxNode declaration)
}

internal override bool IsPrimaryConstructorDeclaration(SyntaxNode declaration)
=> declaration.Parent is TypeDeclarationSyntax { ParameterList: var parameterList } && parameterList == declaration;
=> declaration.Parent is TypeDeclarationSyntax { ParameterList: var parameterList } and not ExtensionBlockDeclarationSyntax && parameterList == declaration;

internal override bool IsConstructorWithMemberInitializers(ISymbol symbol, CancellationToken cancellationToken)
{
Expand Down Expand Up @@ -1643,6 +1643,10 @@ private static bool GroupBySignatureEquivalent(IMethodSymbol? oldMethod, IMethod
return GetDiagnosticSpan(typeDeclaration.Modifiers, typeDeclaration.Keyword,
typeDeclaration.TypeParameterList ?? (SyntaxNodeOrToken)typeDeclaration.Identifier);

case SyntaxKind.ExtensionBlockDeclaration:
var extensionBlockDeclaration = (ExtensionBlockDeclarationSyntax)node;
return extensionBlockDeclaration.Keyword.Span;

case SyntaxKind.BaseList:
var baseList = (BaseListSyntax)node;
return baseList.Types.Span;
Expand Down Expand Up @@ -2248,6 +2252,9 @@ internal override string GetDisplayName(IMethodSymbol symbol)

return CSharpFeaturesResources.local_variable_declaration;

case SyntaxKind.ExtensionBlockDeclaration:
return FeaturesResources.extension_block;

default:
return null;
}
Expand Down Expand Up @@ -2395,6 +2402,11 @@ private void ClassifyInsert(SyntaxNode node)
{
switch (node.Kind())
{
case SyntaxKind.ExtensionBlockDeclaration:
// https://github.com/dotnet/roslyn/issues/78959 Disallowed for now
ReportError(RudeEditKind.Insert);
return;

case SyntaxKind.ExternAliasDirective:
ReportError(RudeEditKind.Insert);
return;
Expand Down Expand Up @@ -2425,6 +2437,11 @@ private void ClassifyDelete(SyntaxNode oldNode)
ReportError(RudeEditKind.Delete);
return;

case SyntaxKind.ExtensionBlockDeclaration:
// https://github.com/dotnet/roslyn/issues/78959 Disallowed for now
ReportError(RudeEditKind.Delete);
return;

case SyntaxKind.AttributeList:
case SyntaxKind.Attribute:
// To allow removal of attributes we need to check if the removed attribute
Expand Down
12 changes: 12 additions & 0 deletions src/Features/CSharp/Portable/EditAndContinue/SyntaxComparer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ internal enum Label

TypeDeclaration,
EnumDeclaration,
ExtensionBlockDeclaration, // tied to parent
BaseList, // tied to parent
PrimaryConstructorBase, // tied to parent
DelegateDeclaration,
Expand Down Expand Up @@ -195,6 +196,7 @@ private static int TiedToAncestor(Label label)
case Label.Parameter:
case Label.AttributeList:
case Label.Attribute:
case Label.ExtensionBlockDeclaration:
return 1;

// Statement syntax
Expand Down Expand Up @@ -681,6 +683,9 @@ private static Label ClassifyTopSyntax(SyntaxKind kind, SyntaxNode? node, out bo
}

break;

case SyntaxKind.ExtensionBlockDeclaration:
return Label.ExtensionBlockDeclaration;
}

// If we got this far, its an unlabelled node. For top
Expand Down Expand Up @@ -917,6 +922,10 @@ protected override bool TryComputeWeightedDistance(SyntaxNode leftNode, SyntaxNo
distance = ComputeDistance((AttributeSyntax)leftNode, (AttributeSyntax)rightNode);
return true;

case SyntaxKind.ExtensionBlockDeclaration:
distance = ComputeDistance((ExtensionBlockDeclarationSyntax)leftNode, (ExtensionBlockDeclarationSyntax)rightNode);
return true;

default:
var leftName = TryGetName(leftNode);
var rightName = TryGetName(rightNode);
Expand Down Expand Up @@ -1435,6 +1444,9 @@ private static double CombineOptional(
case SyntaxKind.DelegateDeclaration:
return ((DelegateDeclarationSyntax)node).Identifier;

case SyntaxKind.ExtensionBlockDeclaration:
return null;

case SyntaxKind.FieldDeclaration:
case SyntaxKind.EventFieldDeclaration:
case SyntaxKind.VariableDeclaration:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ CompilationUnitSyntax unit when unit.ContainsGlobalStatements()
when !fieldDeclaration.Modifiers.Any(SyntaxKind.ConstKeyword)
=> new FieldWithInitializerDeclarationBody(variableDeclarator),

ParameterListSyntax { Parent: TypeDeclarationSyntax typeDeclaration }
ParameterListSyntax { Parent: TypeDeclarationSyntax typeDeclaration and not ExtensionBlockDeclarationSyntax }
=> typeDeclaration is { BaseList.Types: [PrimaryConstructorBaseTypeSyntax { }, ..] }
? new PrimaryConstructorWithExplicitInitializerDeclarationBody(typeDeclaration)
: new PrimaryConstructorWithImplicitInitializerDeclarationBody(typeDeclaration),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public static string GetResource(string keyword)
"top-level statement" => CSharpFeaturesResources.top_level_statement,
"top-level code" => CSharpFeaturesResources.top_level_code,
"class with explicit or sequential layout" => string.Format(FeaturesResources.class_with_explicit_or_sequential_layout),
"extension block" => FeaturesResources.extension_block,
_ => null
};

Expand Down
Loading
Loading