Skip to content
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

The BuilderPatternFunctionsRewriter class has some incorrect handling methods. #145

Open
Shiling1234 opened this issue Nov 10, 2024 · 1 comment

Comments

@Shiling1234
Copy link

orgin code is:
` private static ClassA staicField;

    public static ClassA GetStaicField()
    {
        return staicField;
    }`

will be written to
` private static ClassA staicField;

    public static ClassA_Patched_0 GetStaicField()
    {
        return staicField;
    }`

The above code may lead to type mismatch errors.

Only "return this" needs to be rewrite. Perhaps it is necessary to add a check for whether there is a "return this".

static bool ReturnsThis(MethodDeclarationSyntax method)  
    {  
        var returnStatements = method.DescendantNodes().OfType<ReturnStatementSyntax>();  
        
       return returnStatements.All(r => r.Expression is ThisExpressionSyntax);
    }
@handzlikchris
Copy link
Owner

Thanks - I'll try to have a look, btw if you already have a fix ready it'd be great to have that as PR.

I think rewritter you want is here FastScriptReload.Editor.Compilation.CodeRewriting.BuilderPatternFunctionsRewriter.BuilderPatternFunctionsRewriter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants