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

CS9077 and CS8350 errors in auto generated godot files #1

Closed
delinx32 opened this issue Jul 9, 2023 · 3 comments
Closed

CS9077 and CS8350 errors in auto generated godot files #1

delinx32 opened this issue Jul 9, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@delinx32
Copy link

delinx32 commented Jul 9, 2023

Not sure what i'm missing from the tutorial. I've gone through it several times, but my project won't build.

Error CS8350 This combination of arguments to 'AvaloniaControl.InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)' is disallowed because it may expose variables referenced by parameter 'method' outside of their declaration scope GREM Godot.SourceGenerators\Godot.SourceGenerators.ScriptMethodsGenerator\Grem.Scenes.UserInterface_ScriptMethods.generated.cs 33 Active

Error CS9077 Cannot return a parameter by reference 'method' through a ref parameter; it can only be returned in a return statement GREM Godot.SourceGenerators\Godot.SourceGenerators.ScriptMethodsGenerator\Grem.Scenes.UserInterface_ScriptMethods.generated.cs 33 Active

The auto generated code in question is:

protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret) { if (method == MethodName._Ready && args.Count == 0) { _Ready(); ret = default; return true; } if (method == MethodName._Process && args.Count == 1) { _Process(global::Godot.NativeInterop.VariantUtils.ConvertTo<double>(args[0])); ret = default; return true; } **return base.InvokeGodotClassMethod(method, args, out ret);** }

Any idea on where to start fixing this?

@delinx32
Copy link
Author

delinx32 commented Jul 9, 2023

I was able to get past this by adding this stuff to my csproj:

	<LangVersion>11.0</LangVersion>
	<AnalysisMode>Recommended</AnalysisMode>
	<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
	<IsPackable>false</IsPackable>

Not sure which one fixed it (probably the avalonia one?), but the project builds. The designer still won't work. It's looking in the wrong directory for the dll (the .godot folder instead of the actual bin). Still trying to figure that one out. It happens in my project and the sample projects.

@MrJul
Copy link
Owner

MrJul commented Jul 9, 2023

Thanks for the report, it's <LangVersion>11.0</LangVersion> that fixes it.

Estragonia targets C# 11, which has a breaking change regarding ref structs escape analysis. Projects targeting C# 10 (which is the default for net6.0 projects generated by Godot) are unable to call the method.

I'll change the target language level used by the library to C# 10 for now, as C# 11 isn't really needed. With this change, consuming projects can be either C# 10 or 11 and it'll work.


Regarding the previewer, which IDE are you using with which plugin? I just tested:

  • Fresh git clone of Estragonia
  • Open the GameMenu.sln sample in VS2022 with AvaloniaVS installed
  • Build the solution
  • The designer shows without any issue

Same thing with Rider with AvaloniaRider.
What error do you get?

Note that the Godot SDK sets the project output path to .godot\mono\temp\bin so it's normal for the assemblies to be searched there. It should be completely transparent to the previewer, which uses whatever output path is configured.

Would you mind opening another issue or discussion regarding the previewer to keep it separate from the C# errors?

@MrJul MrJul closed this as completed in da89309 Jul 9, 2023
@MrJul
Copy link
Owner

MrJul commented Jul 9, 2023

Fixed in 1.0.1: please update if you don't want to have to target C# 11.

@MrJul MrJul added the bug Something isn't working label Sep 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants