-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix record short syntax rewriting issue #115
Comments
Actually the issue is witch the record keyword itself not specifically on the shortcut syntax of records. |
Also :
|
Alright, I think I got it, I post the workaround here and either I'll do a PR or someone else after further testing, for now it looks okay with the regular and the shotcut syntax. using FastScriptReload.Runtime;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
namespace FastScriptReload.Editor.Compilation.CodeRewriting
{
class RecordeRewriter : FastScriptReloadCodeRewriterBase
{
public RecordeRewriter(bool writeRewriteReasonAsComment)
: base(writeRewriteReasonAsComment)
{
}
public override SyntaxNode VisitRecordDeclaration(RecordDeclarationSyntax node)
{
return AdjustRecordName(node, node.Identifier);
}
private SyntaxNode AdjustRecordName(RecordDeclarationSyntax node, SyntaxToken nodeIdentifier)
{
var typeName = nodeIdentifier.ToString(); //Not ToFullString() as it may include spaces and break.
if (!typeName.EndsWith(AssemblyChangesLoader.ClassnamePatchedPostfix))
{
typeName += AssemblyChangesLoader.ClassnamePatchedPostfix;
}
return AddRewriteCommentIfNeeded(
node.ReplaceToken(nodeIdentifier, SyntaxFactory.Identifier(typeName)),
$"{nameof(RecordeRewriter)}:{nameof(AdjustRecordName)}"
);
}
}
} |
Thanks - that looks good, and targetting just |
Related to discussion in #111
I believe we could have a small patch that takes care of renaming records under the shortcut syntax with the missing _patched suffix.
The text was updated successfully, but these errors were encountered: