Commit graph

226 commits

Author SHA1 Message Date
Ignacio Etcheverry c55ce204b3 Replace 'ERR_EXPLAIN' with 'ERR_FAIL_*_MSG' in 'modules/mono'
And 'CRASH_*_MSG' as well.

Also make error messages puntuation and quotation more consistent.
2019-08-09 12:13:21 +02:00
Ignacio Etcheverry 0b94203a79 C#: Add Ide Connection library and server for the editor
This will be used for communicating between the Godot editor and external IDEs/editors, for things like opening files, triggering hot-reload and running the game with a debugger attached.
2019-08-04 01:57:53 +02:00
Ignacio Etcheverry c9befa63d2 Mono: Don't try to update project assemblies from project manager
Previously, when running the project manager, we would try to load the API assemblies from the project and fail because we were not editing any project. This would make us try to copy the prebuilt API assemblies to the project. Since there is no project, it would try to copy them to the executable location. This would fail if Godot doesn't have permissions to write to that location.
This commit fixes that by instead trying to load the prebuilt API assemblies in the first place, if running the project manager.
2019-07-25 17:52:45 +02:00
Ignacio Etcheverry 513cc78f85 Mono: Add option to keep running after unhandled exceptions
By default, an unhandled exception will cause the application to be terminated; but the project setting `mono/unhandled_exception_policy` was added to change this behaviour.
The editor is hard-coded to never terminate because of unhandled exceptions, as that would make writing editor plugins a painful task, and we cannot kill the editor because of a mistake in a thirdparty plugin.
2019-07-24 23:19:15 +02:00
Ignacio Etcheverry 0197d86ab4 Mono: Fix editor API assembly not being updated
If both the core and editor API assemblies are missing or out of sync, Godot will only update the former and then abort when trying to load them again because the latter was not updated. Godot will update it correctly the next time it's started, but this should not be needed and it should work the first time. This commit fixes that.
2019-07-22 00:16:24 +02:00
Ignacio Etcheverry ec679dfffa Fix mono module build errors for release templates 2019-07-20 15:52:26 +02:00
Ignacio Etcheverry e59ac40712 Mono: Better handling of missing/outdated API assemblies
Remove the old API assembly invalidation system. It's pretty simple since now the editor has a hard dependency on the API assemblies and SCons takes care of prebuilding them.
If we fail to load a project's API assembly because it was either missing or outdated, we just copy the prebuilt assemblies to the project and try again. We also do this when creating the solution and before building, just in case the user removed them from the disk after they were loaded.
This way the API assemblies will be always loaded successfully. If they are not, it's a bug.

Also fixed:

- EditorDef was behaving like GlobalDef in GodotTools.
- NullReferenceException because we can't serialize System.WeakReference yet. Use Godot.WeakRef in the mean time.
2019-07-14 19:17:07 +02:00
Rémi Verschelde d2e620b8fc
Merge pull request #30463 from neikeq/fix-search-dirs
Fix export templates ignoring assemblies in 'res://.mono/assemblies'
2019-07-09 21:59:32 +02:00
Ignacio Etcheverry df6d1656fe Fix export templates ignoring assemblies in 'res://.mono/assemblies' 2019-07-09 16:49:02 +02:00
Ignacio Etcheverry 069af23bdb Mono: Fix build errors with tools=no 2019-07-08 18:07:20 +02:00
Ignacio Etcheverry 5ed3d34cd9 Fix --generate-mono-glue bug when directory doesn't exist
DirAccess::get_full_path(path) only works if the path exists. Implement our own abspath function.
2019-07-08 18:07:15 +02:00
Ignacio Etcheverry 270af6fa08 Re-write mono module editor code in C#
Make the build system automatically build the C# Api assemblies to be shipped with the editor.
Make the editor, editor player and debug export templates use Api assemblies built with debug symbols.
Always run MSBuild to build the editor tools and Api assemblies when building Godot.
Several bugs fixed related to assembly hot reloading and restoring state.
Fix StringExtensions internal calls not being registered correctly, resulting in MissingMethodException.
2019-07-05 09:38:23 +02:00
Ignacio Etcheverry 9f1a8ce6a2 Mono: Android build and shared libraries fixes
Fix location of Mono's shared libraries.
Fix build failing if the directory 'platform/android/java/libs/{target}/{abi}' doesn't exist.
2019-07-03 17:48:12 +02:00
qarmin 4e5310cc60 Some code changed with Clang-Tidy 2019-06-26 15:08:25 +02:00
JohnJLight 38d3bfe971 Made use of semicolons more consitent, fixed formatting 2019-06-19 15:24:31 +02:00
Ignacio Etcheverry 14df9e5cb2 Android build and export for the mono module 2019-06-03 17:09:24 +02:00
Ignacio Roldán Etcheverry e2375f487c
Merge pull request #29079 from neikeq/oopsie
Fix C# build error in MarshalUtils debug code
2019-05-21 19:54:34 +02:00
Ignacio Etcheverry 9b76c56098 Fix C# build error in MarshalUtils debug code 2019-05-21 19:09:00 +02:00
Ignacio Etcheverry 66b930a266 Replace call to 'mono_runtime_object_init' with manual ctor invoking 2019-05-21 00:06:04 +02:00
Ignacio Etcheverry 5a4bf4f369 C#: Marshalling support for IEnumerable<> and IDictionary<,>
Also fixed the hint string of exported members.
2019-05-18 19:39:56 +02:00
Ignacio Etcheverry 470b80cc55 C#: Support resource type hint in exported arrays
- Elements of types like PackedScene will display with the special editor for such type.
2019-04-29 21:20:05 +02:00
Rémi Verschelde 554c0ea90b
Merge pull request #28423 from neikeq/dont-forget-to-think-a-name-for-this-branch
C#: Deprecate accessor methods and generate correct int and float types
2019-04-29 16:56:25 +02:00
Ignacio Etcheverry 791e1294c3 Mono: Lazily load scripts metadata file
- Only load the scripts metadata file when it's really needed. This way we avoid false errors, when there is no C# project,  about missing scripts metadata file.
2019-04-26 19:53:44 +02:00
Ignacio Etcheverry c20a3823a2 C# bindings generator cleanup
- Normal log messages are no longer warnings.
- BindingsGenerator is no longer a singleton.
- Added a log function.
2019-04-25 20:34:28 +02:00
Ignacio Etcheverry d93c354807 Fix invalid mono log file name on Windows 2019-04-24 18:52:03 +02:00
Ignacio Etcheverry 8759c0e31a Mono: Use exit(status) instead of abort() in exception hook 2019-04-18 15:01:50 +02:00
Ignacio Etcheverry 20e5e2fec7 Mono: Logging improvements
- The default log level in debug builds is now 'info' instead of 'debug'.
- Add option to specify a different log level with the 'GODOT_MONO_LOG_LEVEL' environment variable.
- The name of log files is now a readable date and time.
- Always print the log file path (previously it was printed only it in verbose mode).
2019-04-17 23:03:32 +02:00
Rémi Verschelde 918de768a5
Merge pull request #27711 from neikeq/ifdef-clang-tidy
Replace a few #if/#elif with #ifdef and "#elif defined"
2019-04-08 12:24:30 +02:00
Ignacio Etcheverry 480d4c6fba C#: Support type hints for exported Arrays
Added the code for Dictionary as well, but it's not yet supported by the Godot inspector.
2019-04-06 12:14:43 +02:00
Ignacio Etcheverry 187e6ae26d C#: Add marshalling support for IEnumerable and IDictionary
Added constructor that takes IEnumerable for Array and IEnumerable<T> for Array<T>.
Added constructor that takes IDictionary for Dictionary and IDictionary<TKey, TValue> for Dictionary<TKey, TValue>.
2019-04-06 12:14:37 +02:00
Ignacio Etcheverry ad2127a3e8 Replace a few #if/#elif with #ifdef and "#elif defined" 2019-04-05 23:41:51 +02:00
Ignacio Etcheverry e9e7aab8eb Mono: Some assembly referencing changes and cleanup
Apparently we don't need to call mono_debug_close_image ourselves and we can call mono_image_close right away as it's not our duty to keep that reference.
2019-03-10 18:55:31 +01:00
Ignacio Etcheverry 4299332ecc Mono: Fix assemblies path String incorrectly constructed from utf8
Also fixed a wrong ifdef that was causing Mono to never be initialized if mscorlib was not found (which was the case with the utf8 assemblies path bug this commit fixes).
This condition was meant for exported projects only, not for the editor only.
2019-03-09 23:00:03 +01:00
Ignacio Roldán Etcheverry 65487ed4ed
Merge pull request #26746 from shartte/godot-trace-listener
Add a custom TraceListener on Startup for Mono
2019-03-08 07:05:41 +01:00
Sebastian Hartte 37d448fca7 Added a Godot TraceListener, which is automatically installed on startup. Fixes that Debug/Trace Assertions are simply swallowed by Godot. 2019-03-07 21:00:19 +01:00
Ignacio Etcheverry e904f814c8 Mono: Fix crash when re-using script binding after domain reloading 2019-03-07 19:55:40 +01:00
Ignacio Etcheverry 6492de800f
Merge pull request #26661 from neikeq/issue-17601
Mono: Fix array field being assigned MonoArray** instead of MonoArray*
2019-03-05 23:03:25 +01:00
Ignacio Etcheverry c6ac7333a6 Mono: Fix array field being assigned MonoArray** instead of MonoArray*
Fixes #17601
2019-03-05 21:46:55 +01:00
Rémi Verschelde 0a7de5472f
Merge pull request #26591 from neikeq/oi
Mono: Add option to print MSBuild output and improve out of sync error
2019-03-04 18:36:10 +01:00
Ignacio Etcheverry 8877b07f4c Mono: Add option to print MSBuild output and improve out of sync error 2019-03-04 16:05:08 +01:00
Carter Anderson 839ed2d092 Add mono log profiler support 2019-03-02 23:32:03 -08:00
marxin e5f665c718 Fix -Wsign-compare warnings.
I decided to modify code in a defensive way. Ideally functions
like size() or length() should return an unsigned type.
2019-02-27 07:45:57 +01:00
marxin 8d51618949 Add -Wshadow=local to warnings and fix reported issues.
Fixes #25316.
2019-02-20 19:44:12 +01:00
Ignacio Etcheverry 9421da57ad C#: Add 'Singleton' property to singleton wrapper class
This property returns an instance of the singleton.
The purpose of this is to allow using methods from the base class like 'Connect'.
Since all Godot singletons inherit Object, the type of the returned instance is Godot.Object.
2019-02-19 22:38:22 +01:00
Ignacio Etcheverry 1174d10e3c
Merge pull request #25890 from neikeq/issue-25818
Fix Godot.Reference marshalling from MonoObject* to Variant
2019-02-19 15:05:05 +01:00
Ignacio Etcheverry a8dfe9ff7f Don't print 'Cannot find Mono in the registry' if bundled with Godot
Closes #24753
2019-02-15 19:52:32 +01:00
Ignacio Etcheverry d17ba9a140 Mono: Fix export template build errors
Fixes #25903
2019-02-15 19:52:22 +01:00
Ignacio Etcheverry b41a793592 Fix Godot.Reference marshalling from MonoObject* to Variant
Need to cast Ref<T> to Variant instead of constructing Variant from Object*, otherwise the Variant won't hold a reference.
2019-02-14 22:54:15 +01:00
Rémi Verschelde 55ca2a7c88
Merge pull request #25821 from akien-mga/sync-class-and-filenames
Ensure classes match their header filename
2019-02-13 08:49:39 +01:00
Rémi Verschelde fe7e11e008 Modules: Ensure classes match their header filename
Renamed:
- `modules/mono/mono_gd/gd_mono_class_member.h` -> `i_mono_class_member.h`
- `modules/upnp/upnpdevice.h` -> `upnp_device.h`
- `modules/websocket/websocket_multiplayer.h` -> `websocket_multiplayer_peer.h`
2019-02-12 22:59:56 +01:00
Rémi Verschelde c4835c4345
Merge pull request #25721 from neikeq/ww
Use script instance binding for objects constructed from C#
2019-02-12 15:29:25 +01:00
Ignacio Etcheverry 24a2ae7f3c Do not initialize Mono if 'res://.mono/' and mscorlib are missing
This is needed to avoid aborting due to missing mscorlib for projects that do not use C#.
If 'res://.mono/' exists, then we assume the project uses C#, in which case a missing mscorlib should still abort.
2019-02-10 18:34:37 +01:00
Ignacio Etcheverry 9df44c2d2c Use script instance binding for objects constructed from C#
Only possible if the object class is a "native type". If the object class is a user class (that derives a "native type") then a script is needed.
Since CSharpLanguage does cleanup of script instance bindings when finished, cases like #25621 will no longer cause problems.

Fixed ~Object() trying to free script instance bindings after the language has already been removed, which would result in a NULL dereference.
2019-02-09 00:32:18 +01:00
Ignacio Etcheverry 919fa75803
Merge pull request #25574 from neikeq/ss
Mono: Lifetime fixes for CSharpInstance and instance binding data
2019-02-03 07:36:33 +01:00
Ignacio Etcheverry d8593747e0 Mono: Fix default debugger agent argument never being used 2019-02-03 06:51:07 +01:00
Ignacio Etcheverry 3233083f63 Mono: Lifetime fixes for CSharpInstance and instance binding data
Avoid CSharpInstance from accessing its state after self destructing (by deleting the Reference owner).
It's now safe to replace the script instance without leaking or crashing.

Also fixed godot_icall_Object_weakref return reference being freed before returning.
2019-02-03 06:47:25 +01:00
Ignacio Etcheverry 065828d159 Mono: Fix MonoPosixHelper not being found 2019-02-03 05:38:47 +01:00
Ignacio Etcheverry d3c51a5dfb Mono: Cleanup 2019-02-03 05:38:40 +01:00
Ignacio Etcheverry bc8b61bb06 Mono: Fix hot reload build errors and cleanup 2019-01-22 18:33:36 +01:00
Ignacio Etcheverry 077e489773 Mono: Add assembly reloading to running games
Add environment variable to specify a custom --debugger-agent for mono.
2019-01-21 22:44:09 +01:00
Rémi Verschelde b16c309f82 Update copyright statements to 2019
Happy new year to the wonderful Godot community!
2019-01-01 12:58:10 +01:00
Rémi Verschelde d1f3b622f0 Fix missing/malformed license headers 2019-01-01 12:46:36 +01:00
Hein-Pieter van Braam 4e25e5066b Reduce String CoW
By introducing an intermediate proxy class for the array subscript
operator for String and CharString we can control better when CowData
will actually CoW.

This should improve performance of String usage for most cases.
2018-12-16 16:51:38 +01:00
Ben Rog-Wilhelm b26487a2b4 Tweaks after feedback 2018-12-08 00:54:12 -08:00
Ben Rog-Wilhelm f13f2d512f Implement CSharpScript::get_script_method_list and related functionality. 2018-12-07 23:54:40 -08:00
Ignacio Etcheverry 989b93d6a4
Merge pull request #24091 from neikeq/ii
C#: Improve tool script support and fix reloading issues
2018-11-30 21:39:13 +01:00
Ignacio Etcheverry b9b7dcdf00 C#: Improve tool script support and fix reloading issues 2018-11-30 20:43:06 +01:00
Ignacio Etcheverry 6d7dc9d98b
Merge pull request #23583 from neikeq/ee
Improve the C# API projects generation
2018-11-08 01:52:27 +01:00
Ignacio Etcheverry 02d5ff4cd0 Improve the C# API projects generation
- Now there is only one solution that contains both GodotSharp and GodotSharpEditor project. Previously we had one solution for each project
- GodotSharpEditor reference GodotShatp with a 'ProjectReference'. Previously it was a 'Reference' to the assembly
- This also simplifies the command line option to generate this solution: 'godot --generate-cs-api <OutputDir>'
2018-11-08 01:05:22 +01:00
Ryan Schmitt 366c7e0f48 Fix false error when exporting enum in c# 2018-11-05 01:22:15 -08:00
Ignacio Etcheverry d47cec43f2
Merge pull request #23162 from neikeq/cc
Proper support for namespaces and other enhancement/fixes
2018-10-25 18:18:40 +02:00
Ignacio Etcheverry 1aac95a737 Parse C# script namespace and class
- Added a very simple parser that can extract the namespace and class name of a C# script.
2018-10-25 18:00:24 +02:00
Ignacio Etcheverry 454b933106 Fix internal assembly load from
- Also make sure we load API assemblies from 'res://.mono/assemblies/'.
2018-10-22 20:35:44 +02:00
Mads Ynddal 16c0c037c8 Removed undeclared and unused variable, which caused a compile error 2018-10-21 21:55:30 +02:00
Ignacio Etcheverry 23ae64b15e C#: Optimize struct marshalling
- We no longer box struct to return them from internal calls.
- Use reinterpret_cast if the managed struct layout is the same as the native struct.
2018-10-17 22:36:26 +02:00
Ignacio Etcheverry b63e518ce9 Mono: Fix crash on NodePath/RID disposal during Godot shutdown 2018-10-06 23:00:18 +02:00
Ignacio Etcheverry 9475e86078 Fix build error for windows mono export templates 2018-10-05 17:47:34 +02:00
Ignacio Etcheverry d7ece43b74 Mono: Editor and export template dependencies and fixes
- Bundle editor dependencies:
    - 'GodotSharp': Root data directory for the editor
        - 'Tools': Editor dependencies. Only GodotSharp.dll for now.
        - 'Api': Prebuilt GodotSharp and GodotSharpEditor API assemblies.
        - 'Mono': Mono files to bundle with the editor.
            - 'bin': (Optional, not used for now) Mono bin directory.
            - 'etc': Mono configuration files.
            - 'lib': Mono dependency shared libraries.
            - 'lib/mono/4.5': Framework assemblies.
    - Added build option to copy the required files from the mono installation to 'GodotSharp/Mono'. Enable with 'copy_mono_root=yes'. Disabled by default.

- Export template dependencies:
    - 'data_AppName'/'data_Godot':
        - 'Mono': Mono files to bundle with the game.
            - 'etc': Mono configuration files.
            - 'lib': Mono dependency shared libraries.
    - The data directory is generated when compiling and must be bundled with the export templates. In the case of OSX, the data directory must be placed inside the 'osx.zip' export template.
    - In OSX, alternative location for directories (needed for app bundles) are:
        - 'data_AppName/Mono/etc' --> '../Resources/GodotSharp/Mono/etc'
        - 'data_AppName/Mono/lib' --> '../Frameworks/GodotSharp/Mono/lib'

- The editor can bundle prebuilt API assemblies.
    - Generate them with a tools build by running: `--generate-cs-core-api <GodotSharp_OutputDir> --generate-cs-editor-api <GodotSharpEditor_OutputDir> <GodotSharp_OutputDir>/bin/Release/GodotSharp.dll` (This command will be simplified in the future and both projects will be in the same solution)
    - Build the solutions and copy the output files to '#bin/GodotSharp/Api'.
- Fixed API assembly being added twice during the export process.
2018-10-03 19:16:29 +02:00
Ignacio Etcheverry 50fd5ef3b5 Mono: Fix not creating generic Array or Dictionary where expected 2018-09-27 00:11:31 +02:00
Ignacio Etcheverry 0f3de6ef3a Do not update cache if the C# API assembly is out of sync 2018-09-26 23:59:38 +02:00
Ignacio Etcheverry 50f6dbff87 Mono: Fix opening code editors in OSX and cleanup 2018-09-17 20:00:19 +02:00
Fabio Alessandrelli d6b31daec6 Rename slave keyword to puppet
The slave keyword will still be available as deprecated in 3.1 but will
be dropped from future releases.
2018-09-15 00:06:03 +02:00
Rémi Verschelde 1a16dabfb5
Merge pull request #21982 from luzpaz/misc-typos
Misc. typos
2018-09-13 10:59:00 +02:00
luz.paz 08bde5b2de Misc. typos
Found via `codespell -q 3 -I ../godot-word-whitelist.txt --skip="./thirdparty,*.po"`
2018-09-12 21:39:17 -04:00
Ignacio Etcheverry 6ae47ff19b C#: Fix explicit enum values when exporting member 2018-09-12 18:54:20 +02:00
Rémi Verschelde 277b24dfb7 Make core/ includes absolute, remove subfolders from include path
This allows more consistency in the manner we include core headers,
where previously there would be a mix of absolute, relative and
include path-dependent includes.
2018-09-12 09:52:22 +02:00
Ignacio Etcheverry d21c64cc3b C#: Fix cs_files glue mismatch bug 2018-09-12 03:24:08 +02:00
Ignacio Etcheverry e558e1ec09 Fix/workaround for issue #21667
When a Reference managed instance is garbage collected and its finalizer is called, it could happen that the native instance is referenced once again before the finalizer can unreference and memdelete it. The workaround is to create a new managed instance when this happens (at least for now).
2018-09-12 03:24:08 +02:00
Ignacio Etcheverry 61426464ea Add some mono root hint dirs for OSX
Fixes #13355
2018-09-12 03:24:08 +02:00
Ignacio Etcheverry b1356a3590 Cleanup of c# api files and bindings generator
- We no longer generate RID and NodePath C# classes. Both will be maintained manually.
- We no longer generate C# declarations and runtime registration of internal calls for the following classes: RID, NodePath, String, GD, SignalAwaiter and Godot.Object (partial base).
- We no longer auto-generate the base members of Godot.Object. They will be maintained manually as a partial class.

This makes it easier to maintain these C# classes and their internal calls, as well as the bindings generator which no longer generates C# classes that don't derive from Godot Object, and it no longer generates the Godot.Object base members (which where unreadable in the bindings generator code).

- Added missing 'RID(Object from)' constructor to the RID C# class.
- Replaced MONO_GLUE_DISABLED constant macro with MONO_GLUE_ENABLED.
- Add sources in module/mono/glue even if glue is disabled, but surround glue files with ifdef MONO_GLUE_ENABLED.
2018-09-12 03:23:45 +02:00
exts 035d498af2 Added Collections namespace to Array & Dictionary 2018-08-25 17:19:37 -05:00
Ignacio Etcheverry d72a281468
Merge pull request #20717 from PJB3005/18-08-04-godot-exceptions
Fix Mono exception handling.
2018-08-24 16:27:43 +02:00
Rémi Verschelde de59fe04e7 Add print_verbose to print to stdout only in verbose mode
Equivalent of the cumbersome:
if (OS::get_singleton()->is_stdout_verbose())
	print_line(msg);
2018-08-24 09:23:20 +02:00
Pieter-Jan Briers af39684885 Fix Mono exception handling.
First of all, this fixes the handling of exceptions so the engine actually notices them,
it was broken in 4172fa03b5.

Next, unhandled exceptions now do NOT cause an abort(). They're logged now,
so before #16987. The pending exception thing still works though.
2018-08-23 20:21:36 +02:00
Ignacio Etcheverry 143c471eff Mono: Fix weird crash when loading corlib 2018-08-22 00:49:38 +02:00
Ignacio Etcheverry 5df91099c7
Merge pull request #18502 from space-wizards/18-04-29-assembly-load-hook
assembly_load_hook fallback for registering GDMonoAssemblies.
2018-08-22 00:27:35 +02:00
Juan Linietsky ea3d997f9d
Revert "added get_creation_time function for gdscript" 2018-08-10 13:29:49 -03:00
Juan Linietsky 275e0d5ee4
Merge pull request #18914 from notwarp/master
added get_creation_time function for gdscript
2018-08-10 13:28:47 -03:00
Ignacio Etcheverry 4172fa03b5 Mono: Fix property set_value and cleanup 2018-07-31 19:49:16 +02:00
Hein-Pieter van Braam 0e29f7974b Reduce unnecessary COW on Vector by make writing explicit
This commit makes operator[] on Vector const and adds a write proxy to it.  From
now on writes to Vectors need to happen through the .write proxy. So for
instance:

Vector<int> vec;
vec.push_back(10);
std::cout << vec[0] << std::endl;
vec.write[0] = 20;

Failing to use the .write proxy will cause a compilation error.

In addition COWable datatypes can now embed a CowData pointer to their data.
This means that String, CharString, and VMap no longer use or derive from
Vector.

_ALWAYS_INLINE_ and _FORCE_INLINE_ are now equivalent for debug and non-debug
builds. This is a lot faster for Vector in the editor and while running tests.
The reason why this difference used to exist is because force-inlined methods
used to give a bad debugging experience. After extensive testing with modern
compilers this is no longer the case.
2018-07-26 00:54:16 +02:00