Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix failing test
  • Loading branch information
Youssef1313 authored and Sergio0694 committed Dec 11, 2024
commit 71aeda87f67c305a1534008ee4f5997e0c2ad1dd
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,11 @@ private static async Task<Document> ConvertToPartialProperty(Document document,
// Find the parent type for the property
TypeDeclarationSyntax typeDeclaration = propertyDeclaration.FirstAncestorOrSelf<TypeDeclarationSyntax>()!;

// Make sure it's partial
// Make sure it's partial (we create the updated node in the function to preserve the updated property declaration).
// If we created it separately and replaced it, the whole tree would also be replaced, and we'd lose the new property.
if (!typeDeclaration.Modifiers.Any(SyntaxKind.PartialKeyword))
{
TypeDeclarationSyntax updatedTypeDeclaration = typeDeclaration.AddModifiers(Token(SyntaxKind.PartialKeyword));

editor.ReplaceNode(typeDeclaration, updatedTypeDeclaration);
editor.ReplaceNode(typeDeclaration, static (node, generator) => generator.WithModifiers(node, generator.GetModifiers(node).WithPartial(true)));
}

return document.WithSyntaxRoot(editor.GetChangedRoot());
Expand Down