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

Mono Build Error: Optional parameters must appear after all required parameters #657

Closed
sesopenko opened this issue Nov 30, 2021 · 3 comments

Comments

@sesopenko
Copy link
Contributor

The problem

Describe the bug
When building a Godot Mono project that uses the Dialogic plugin, a build error occurs.

To Reproduce
Steps to reproduce the behavior:

  1. Download and install Godot Mono for Windowx x64, and the documented microsoft SDK on the godot website
  2. Create a new Godot mono project and attach a C# script to the root node of the main scene
  3. Build the project (should build successfully at this stage)
  4. Clone this repo in another folder (used commit 10c14d149e562466b8bb5dc62c8d65d6e7844f3f)
  5. Copy the addons/dialogic folder from the dialogic repo into the project
  6. Create a timeline
  7. Add a single text event to the timeline
  8. Add addons/dialogic/Dialog.tscn to the root node as a child node
  9. Select the timeline created earlier in the propery inspector for the Dialog node
  10. Build the project

Expected behavior
Build error:

<folder path ommitted for privacy>\addons\dialogic\Other\DialogicSharp.cs(16,102): Optional parameters must appear after all required parameters

Solutions

Workaround

No known workaround, it's a build error.

Possible fixes

Short term fix: change add a default value to String dialogScenePath = "". This would be backwards compatible for existing users of the library but I haven't tested if this works.

Long term fix: If dialogScenePath can't be optional and default to "", reorder the parameters. This would be backwards incompatible and require support for downstream users of the library.

@sesopenko
Copy link
Contributor Author

Working on the recommended short term fix now, will have a PR soon.

sesopenko added a commit to sesopenko/dialogic that referenced this issue Nov 30, 2021
When building a Godot Mono 3.4 project using the library a build error
occurs:

`\addons\dialogic\Other\DialogicSharp.cs(16,102): Optional parameters
must appear after all required parameters`

Made set a default parameter for `dialogScenePath` so that ordering
rules for C# are respected and the library builds when used in a
project.

See C# documentation for more details:

https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/named-and-optional-arguments
@sesopenko
Copy link
Contributor Author

I have a PR which I've tested against my own project.

Build results after the fix:

Build with surface heuristics started at 14:36:20
Use build tool: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe
CONSOLE: Microsoft (R) Build Engine version 16.11.2+f32259642 for .NET Framework
CONSOLE: Copyright (C) Microsoft Corporation. All rights reserved.
CONSOLE: Build started 2021-11-30 2:36:20 PM.
CONSOLE: Project "C:\Users\sesop\AppData\Local\Temp\Xekicit.proj" on node 1 (default targets).
CONSOLE: ControllerTarget:
CONSOLE:   Run controller from C:\Program Files\JetBrains\JetBrains Rider 2021.2.2\lib\ReSharperHost\JetBrains.Platform.MsBuildTask.v15.dll
0>------- Started building project: GameCollabFirst
0>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Roslyn\csc.exe /noconfig /unsafe- /checked- /nowarn:1701,1702,1701,1702,2008 /fullpaths /nostdlib+ /errorreport:prompt /warn:4 /define:GODOT;GODOT_WINDOWS;GODOT_PC;TRACE;TOOLS;DEBUG;NETFRAMEWORK;NET472;NET20_OR_GREATER;NET30_OR_GREATER;NET35_OR_GREATER;NET40_OR_GREATER;NET45_OR_GREATER;NET451_OR_GREATER;NET452_OR_GREATER;NET46_OR_GREATER;NET461_OR_GREATER;NET462_OR_GREATER;NET47_OR_GREATER;NET471_OR_GREATER;NET472_OR_GREATER /errorendlocation /preferreduilang:en-US /highentropyva+ /reference:C:\Users\sesop\Documents\github.com\sesopenko\GameCollabFirst\.mono\assemblies\Debug\GodotSharp.dll /reference:C:\Users\sesop\Documents\github.com\sesopenko\GameCollabFirst\.mono\assemblies\Debug\GodotSharpEditor.dll /reference:C:\Users\sesop\.nuget\packages\microsoft.netframework.referenceassemblies.net472\1.0.0\build\.NETFramework\v4.7.2\mscorlib.dll /reference:C:\Users\sesop\.nuget\packages\microsoft.netframework.referenceassemblies.net472\1.0.0\build\.NETFramework\v4.7.2\System.Core.dll /reference:C:\Users\sesop\.nuget\packages\microsoft.netframework.referenceassemblies.net472\1.0.0\build\.NETFramework\v4.7.2\System.Data.dll /reference:C:\Users\sesop\.nuget\packages\microsoft.netframework.referenceassemblies.net472\1.0.0\build\.NETFramework\v4.7.2\System.dll /reference:C:\Users\sesop\.nuget\packages\microsoft.netframework.referenceassemblies.net472\1.0.0\build\.NETFramework\v4.7.2\System.Drawing.dll /reference:C:\Users\sesop\.nuget\packages\microsoft.netframework.referenceassemblies.net472\1.0.0\build\.NETFramework\v4.7.2\System.IO.Compression.FileSystem.dll /reference:C:\Users\sesop\.nuget\packages\microsoft.netframework.referenceassemblies.net472\1.0.0\build\.NETFramework\v4.7.2\System.Numerics.dll /reference:C:\Users\sesop\.nuget\packages\microsoft.netframework.referenceassemblies.net472\1.0.0\build\.NETFramework\v4.7.2\System.Runtime.Serialization.dll /reference:C:\Users\sesop\.nuget\packages\microsoft.netframework.referenceassemblies.net472\1.0.0\build\.NETFramework\v4.7.2\System.Xml.dll /reference:C:\Users\sesop\.nuget\packages\microsoft.netframework.referenceassemblies.net472\1.0.0\build\.NETFramework\v4.7.2\System.Xml.Linq.dll /reference:C:\Users\sesop\.nuget\packages\microsoft.netframework.referenceassemblies.net472\1.0.0\build\.NETFramework\v4.7.2\Facades\netstandard.dll /debug+ /debug:portable /filealign:512 /optimize- /out:C:\Users\sesop\Documents\github.com\sesopenko\GameCollabFirst\.mono\temp\obj\Debug\GameCollabFirst.dll /subsystemversion:6.00 /target:library /warnaserror- /utf8output /deterministic+ /langversion:7.3 /analyzerconfig:C:\Users\sesop\Documents\github.com\sesopenko\GameCollabFirst\.mono\temp\obj\Debug\GameCollabFirst.GeneratedMSBuildEditorConfig.editorconfig addons\dialogic\Other\DialogicSharp.cs "C:\Users\sesop\Documents\github.com\sesopenko\GameCollabFirst\.mono\temp\obj\Debug\.NETFramework,Version=v4.7.2.AssemblyAttributes.cs" C:\Users\sesop\Documents\github.com\sesopenko\GameCollabFirst\.mono\temp\obj\Debug\GameCollabFirst.AssemblyInfo.cs /warnaserror+:NU1605
0>GameCollabFirst -> C:\Users\sesop\Documents\github.com\sesopenko\GameCollabFirst\.mono\temp\bin\Debug\GameCollabFirst.dll
0>------- Finished building project: GameCollabFirst. Succeeded: True. Errors: 0. Warnings: 0
Build completed in 00:00:01.168
Build succeeded at 2:36:21 p.m. 

The build error is gone and now I'm getting the following error when enabling the plugin, which I suspect is unrelated:

--- Debugging process stopped ---
 res://addons/dialogic/Editor/CharacterEditor/CharacterEditor.gd:53 - Invalid call. Nonexistent function 'get_settings_value' in base 'GDScript'.

I created a test scene with a dialog and it now runs successfully in godot mono x64 locally on my machine

Screenshot of it now working:

dialog success

@sesopenko
Copy link
Contributor Author

@coppolaemilio the PR fixing this issue: #658

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

1 participant