Commit graph

1054 commits

Author SHA1 Message Date
Rémi Verschelde 1edd6aa404
Merge pull request #41751 from neikeq/3.2-issue-41745
[3.2] C#: Fix Godot failing to find class namespace
2020-09-04 08:16:30 +02:00
Ignacio Etcheverry 2bb251f628 [3.2] C#: Hide Build button if there's no solution to build
Same as we do with the bottom panel. Mainly to
avoid bothering if the project is not using C#.
2020-09-04 02:18:42 +02:00
Ignacio Etcheverry f8e3a74f9e Fix InvalidOperationException when migrating from 3.2.1 or older csproj 2020-09-04 01:49:32 +02:00
Ignacio Etcheverry b3762622be [3.2] C#: Fix Godot failing to find class namespace
Also avoid searching C# files recursively twice.
2020-09-04 01:31:38 +02:00
Ignacio Etcheverry bd18b2ff6a [3.2] Fix 'Parameter "assembly" is null' error
This error was normally being printed when
trying to open the project assembly while
the project was not yet built.
The error should not be printed. It's the job
of this method's caller to decide whether to
print an error or not if loading failed.
2020-09-04 01:09:35 +02:00
Ignacio Etcheverry 939ed5dd5b C#: Fix Windows detection for copying MSBuild stub
Previous condition checked only the host
platform. This was a problem as our official
builds are from Linux.

(cherry picked from commit 206501a45e)
2020-09-03 09:35:41 +02:00
Thaina Yu cadd39d415
Mono: Improve MSBuildFinder logic on Windows
Support detecting both 32-bit and 64-bit installations of `vswhere.exe`.

(cherry picked from commit 5dc3900727)
2020-08-31 15:29:41 +02:00
Ignacio Etcheverry 789d7fac8a C#: Fix crash on export when incorrectly freeing MonoAssemblyName 2020-08-30 02:01:38 +02:00
Ignacio Etcheverry a8e1a0f0bc
C#: Fix 'Parameter toolsPath cannot be null' error
(cherry picked from commit 2bd6252e92)
2020-08-25 14:36:40 +02:00
Ignacio Etcheverry f3ed06cfd7
Mono/C#: Fix editor using wrong project assembly path in rare cases
We were removing invalid path characters from the
name in C++ code, but the C# editor code wasn't.

(cherry picked from commit 8bb48ae57a)
2020-08-21 02:28:18 +02:00
Ignacio Etcheverry eb30c04c4d
C#: Save newly created csproj files without BOM
(cherry picked from commit b5f6285f34)
2020-08-21 02:28:18 +02:00
Ignacio Etcheverry a7bd28760e
C#: Fix null exception in our MSBuild logger
(cherry picked from commit 7eed8c5a0c)
2020-08-21 02:28:18 +02:00
Ignacio Etcheverry c8845291c3
C#: Fix editor unable to play game after IDE PlayRequest
The editor wasn't clearing the debugger agent
settings properly after a processing a play
request from an IDE. This caused consequent play
attempts to fail if not launched from the IDE,
as the game would still attempt and fail to
connect to the debugger.

The concrete cause: Forgetting to clear the
`GODOT_MONO_DEBUGGER_AGENT` environment variable.

(cherry picked from commit 6e7da72648)
2020-08-21 02:28:18 +02:00
Ignacio Etcheverry c3954441f3 3.2 New csproj style with backport of Godot.NET.Sdk
This is a cherry-pick of
ced77b1e9b
with several 3.2 specific alterations.

There are a lot of build issues coming from
old style projects. At this point fixing every
single one of those would require adding patch
after patch to the project file, which is a
considerable amount work and makes the csproj
even more bloated than it already is.

As such I decided this effort would be better
spent back-porting the Sdk style support that's
already available in 4.0-dev to the 3.2 branch.

This will prevent many issues, but it will also
introduce other benefits, among them:

- While target framework stays as .NET Framework
  v4.7.2, it can be changed to .NET Standard 2.0
  or greater if desired.
- It makes it much easier to add future patches.
  They are added to Godot.NET.Sdk and the only
  change required in Godot code is to update the
  Sdk version to use.
- Default Godot define constants are also
  backported, which fixes IDE issues with the
  preprocessor.

There are a few differences in the changes
applied during patching of the csproj compared
to 4.0 with the purpose of preventing breaking
builds:

- 'TargetFramework' stays net472 both for new
  projects and when importing old ones. It can
  be manually changed to netstandard 2.0+ if
  desired though.

The following features are enabled by default for
new projects. Enabling them in imported projects
may result in errors that must be fixed manually:

- 'EnableDefaultCompileItems' is disabled as it
  can result in undesired C# source files being
  included. Existing include items are kept.
  As long as 'EnableDefaultCompileItems' remains
  disabled, Godot will continue taking care of
  adding and removing C# files to the csproj.
- 'GenerateAssemblyInfo' is disabled as it
  guarantees a build error because of conflicts
  between the existing 'AssemblyInfo.cs' and the
  auto-generated one.
- 'Deterministic' is disabled because it doesn't
  like wildcards in the assembly version (1.0.*)
  that was in the old 'AssemblyInfo.cs'.

Of importance:

This is a breaking change. A great effort was
put in avoiding build errors after upgrading a
project, but there may still be exceptions.

This also breaks forward compatibility. Projects
opened with Godot 3.2.3 won't work out of the box
with older Godot versions. This was already the
case with changes introduced in 3.2.2.

Albeit C# support in 3.2.x was still labeled as
alpha, we've been trying to treat it as stable
for some time. Still the amount of problems this
change solves justifies it, but no more changes
that break project compatibility are to be
introduced from now on (at least for 3.x).
2020-08-20 21:48:59 +02:00
Ignacio Etcheverry 4d7b7d9b73 3.2 C#: Upgrade GodotTools to nuget Microsoft.Build
This upgrade is needed in order to support
reading and editing project files that use Sdks
as well as other new features. A common example
in 3.2 is having to specify a PackageReference
version with a child element rather than the
attribute. This is no longer the case now.

Partial cherry-pick of f3bcd5f8dd
Most of the other changes from that commit were already partially
cherry-picked in 3928fe200f.
2020-08-20 21:45:34 +02:00
Ignacio Etcheverry e1f17a0b35 3.2 C#/Mono: Check assembly version when loading
Not sure if we should check revision too, but this is good enough for what we want.
This will be needed to load the correct Microsoft.Build when we switch to the nuget version.

Manual cherry-pick of af4acb5b11 (relevant parts)
2020-08-20 21:38:33 +02:00
Nhiqill 8d5dab5a05 Pop from front to avoid infinite loop with nested classes
(cherry picked from commit 42d1b4f389)
2020-07-28 00:57:27 +02:00
Rémi Verschelde b40f3f9740 Style: Sync other changes from new fix_style.sh and clang_format.sh 2020-07-24 10:39:18 +02:00
mega-bit 93f297e1d5 Fix typos in GodotSharp code docs
(cherry picked from commit 0ca96ae2c1)
2020-07-24 10:31:57 +02:00
Ignacio Etcheverry accc30e5e0 C#: Fix restore not called when building game projects
(cherry picked from commit 4a30289eee)
2020-07-24 10:31:57 +02:00
Aaron Franke e10a1e078f
[3.2] Add C# XML documentation to core C# math types 2020-07-21 21:22:54 -04:00
Andy Maloney 502a3d580f Remove override keyword from csharp_script.h to fix build errors
Fixes godotengine/godot#40572
2020-07-21 13:17:58 -04:00
endlesstravel 13d4813ddf fix crash when pass null in print array in GD.print
fix crash when pass null in print array in GD.print 2

fix crash when pass null in print array in GD.print 3

fix space

(cherry picked from commit d2461bad63)
2020-07-03 15:38:07 +02:00
Rémi Verschelde d6ff55f30b
Merge pull request #39784 from neikeq/3.2-visualstudio-support
[3.2] C#: Add Visual Studio support
2020-06-26 20:49:35 +02:00
Ignacio Etcheverry c682410379 Mono/C#: Fix unhandled exception not being printed
For some reason `mono_unhandled_exception` is not
printing the exception as its comment claims.
Use `mono_print_unhandled_exception` instead.

(cherry picked from commit f87ae395ee)
2020-06-26 08:10:24 +02:00
Rémi Verschelde c8586d3837
Merge pull request #39840 from neikeq/3.2-use-/restore-instead-of-/t-restore
[3.2] Mono/C#: Use /restore instead of /t:restore when building
2020-06-26 08:08:40 +02:00
Ignacio Etcheverry abc453f9b6 [3.2] Mono/C#: Use /restore instead of /t:restore when building
Documentation recommends not to use /t:restore
together with other targets (like /t:build),
as it messes with the environment.
2020-06-25 23:57:44 +02:00
Ignacio Etcheverry 7af6a4cc50 [3.2] Fix DebugPlay request handler ignoring BuildBeforePlaying
This must have been missed when backporting the new protocol to 3.2.
2020-06-25 21:20:44 +02:00
Ignacio Etcheverry d0f365fe0f [3.2] C#: Fix completion request with case insensitive resource path
Sometimes Visual Studio documents have the root path all in upper case.
Since Godot doesn't support loading resource files with a case insensitive path,
this makes script resource loading to fail when the Godot editor gets code
completion requests from Visual Studio.
This fix allows the resource path part of the path to be case insensitive. It
still doesn't support cases where the rest of the path is also case insensitive.
For that we would need a proper API for comparing paths. However, this fix
should be enough for our current cases.
2020-06-23 21:04:08 +02:00
Ignacio Etcheverry d8af79140e [3.2] C#: Add VisualStudio support 2020-06-23 21:01:54 +02:00
Rémi Verschelde 327479472e Revert "return boxed long when marshalling a godot int to mono runtime in dynamic contexts"
This reverts commit 42a31501a8.

It breaks compat as is and needs some further work before it can be
cherry-picked for 3.2.x.
2020-06-22 08:35:21 +02:00
Michael Belousov 42a31501a8 return boxed long when marshalling a godot int to mono runtime in dynamic contexts
(cherry picked from commit 60fcefba69)
2020-06-19 16:17:27 +02:00
Hugo Locurcio 88c22cb648 Document Mono-specific classes
This fully documents all Mono-specific classes.

(cherry picked from commit 24a8d43272)
2020-06-18 11:33:18 +02:00
Rémi Verschelde bf913d6917 DocData: Skip language-specific ClassDoc without methods/constants
Removes the useless `@C#`, `@NativeScript` and `@VisualScript` entries.

(cherry picked from commit ba0db95909)
2020-06-18 11:29:28 +02:00
Rémi Verschelde 7bf9787921 SCons: Format buildsystem files with psf/black
Configured for a max line length of 120 characters.

psf/black is very opinionated and purposely doesn't leave much room for
configuration. The output is mostly OK so that should be fine for us,
but some things worth noting:

- Manually wrapped strings will be reflowed, so by using a line length
  of 120 for the sake of preserving readability for our long command
  calls, it also means that some manually wrapped strings are back on
  the same line and should be manually merged again.

- Code generators using string concatenation extensively look awful,
  since black puts each operand on a single line. We need to refactor
  these generators to use more pythonic string formatting, for which
  many options are available (`%`, `format` or f-strings).

- CI checks and a pre-commit hook will be added to ensure that future
  buildsystem changes are well-formatted.

(cherry picked from commit cd4e46ee65)
2020-06-10 15:30:52 +02:00
NutmegStudio 96a3b91eee Fixes building mono release templates
(cherry picked from commit a77f633161)
2020-06-04 12:09:40 +02:00
Maganty Rushyendra e34929feaa Update Mono C# warning to reflect latest list of platforms supported
Simple fix for #38627. iOS (#20268) and HTML5 (#20270) removed from list of exceptions
for platforms supported in warning message.

(cherry picked from commit 3d03be7a56)
2020-06-04 12:09:39 +02:00
Ignacio Etcheverry f0bc3482d4 Mono/C#: Don't try to load project assembly in project manager
This was causing an error message when launching the manager,
because there is no project assembly to load.

(cherry picked from commit d7e21ecd63)
2020-05-25 16:34:15 +02:00
Ignacio Etcheverry 0da84b50c0 Mono/C#: Fix values not updated in remote inspector
(cherry picked from commit 51e1614d28)
2020-05-25 11:46:03 +02:00
Ignacio Etcheverry ce09d0c5e1 Add SCons option to not build C# solutions 2020-05-22 03:12:54 +02:00
Ignacio Etcheverry 6dfd80673a Mono/C#: Remove script load error about not a Godot.Object
Any C# file can be loaded as script and at load
time we don't yet know if it's actually meant to
be used as a script. As such, such an check can
result in a lot of false errors.

If the file is really meant to be used as a
script, an error would be printed later when
attempting to instantiate it any way.

(cherry picked from commit 38cd2152e6)
2020-05-20 11:41:01 +02:00
pepegadeveloper123 23d51ac325 Fix inherited C# scene not inheriting parent's fields (3.2)
When a child scene inherits a parent scene with a C# root node, the
parent scene's export variables appear to assume values set in the
parent scene, in the child scene's Inspector. However, when the child
scene is played, the parent scene's export variables assume default
values.
When a node is created, it inherits its parent C# script's fields from
the map CSharpScriptInstance::script->member_info. However this map was
not initialized outside the editor, and this commit ensured it is. This
fixes issues #36480 and #37581.
This is a manual backport of PR #38638 for 3.2.
2020-05-16 11:18:58 +02:00
Ignacio Etcheverry 3928fe200f [3.2] C#: Support for building with the dotnet CLI
By adding a reference to the 'Microsoft.NETFramework.ReferenceAssemblies' nuget
package, we can build projects targeting .NET Framework with the dotnet CLI.
By referencing this package we also don't need to install Mono on Linux/macOS
or .NET Framework on Windows, as the assemblies are taken from the package.
2020-05-11 19:48:50 +02:00
Ignacio Etcheverry 683e19306e Mono: Use msbuild instead of nuget.exe for restoring
- Make GodotTools output directly to the SCons output directory.
- Removed xbuild_fallback from the build system.

(cherry picked from commit b61ffef0ab)
2020-05-11 11:01:13 +02:00
Ignacio Etcheverry 34132d2f67 Mono: Fix hot-reloading of nested classes
(cherry picked from commit e0a001549e)
2020-05-11 11:01:13 +02:00
Ignacio Etcheverry fb2e00a854 [3.2] C#: Rewrite GodotTools messaging protocol 2020-05-10 21:05:00 +02:00
Nannaquin 9e4de37e88 Fix growMargin() not returning modified Rect2/Rect2i
(cherry picked from commit 0ac6f4c40b)
2020-05-01 10:56:58 +02:00
Ignacio Etcheverry 8cdcb410e0 Mono/C#: Fix load hook not called for some assemblies on domain reload
(cherry picked from commit f5510262bc)
2020-04-27 10:15:24 +02:00
Ignacio Etcheverry a98d44f654 C#: Fix always saving copy of csproj even with no changes
This was a regression from 93d7ec8836 (#38110).
Mono's old implementation of Microsoft.Build hardcodes HasUnsavedChanges to
always return true.
This workaround can be reverted once we switch to official Microsoft.Build.

(cherry picked from commit 81f13f6171)
2020-04-27 10:15:07 +02:00
Ignacio Etcheverry 6aca932659 C#: Revert marshalling of IDictionary/IEnumerable implementing types
Added marshalling for `System.Collections.Generic.List<T>` and
`System.Collections.Generic.Dictionary<TKey, TValue>`.
2020-04-23 15:36:01 +02:00
Ignacio Etcheverry dfdb7bdc87 Mono/C#: Fix assemblies being reloaded a second time unnecesarily
(cherry picked from commit c9882e61e2)
2020-04-23 11:34:42 +02:00
Ignacio Etcheverry cf729f2111 Mono/C#: Allow exporting System.Array of type Godot.Object
(cherry picked from commit 0fec3cb5ed)
2020-04-23 11:17:23 +02:00
Ignacio Etcheverry 317d8decad Mono/C#: Allow debugging exported games
- Include PDB files in exported games.
- Release export templates also allow debugging now.

Right now the only way to enable debugging in exported games is with the  environment variables, which may be cumbersome or not even possible on some platforms.

(cherry picked from commit 71fc87e101)
2020-04-23 11:15:35 +02:00
Ignacio Etcheverry 08f41f474b C#: Save copy of sln and csproj before applying fixes
(cherry picked from commit 93d7ec8836)
2020-04-23 11:14:57 +02:00
Rémi Verschelde cb1366f006 Mono: Fix include for Android support
This was a typo in #37153.

Co-authored-by: Ignacio Etcheverry <ignalfonsore@gmail.com>
(cherry picked from commit 408fab8442)
2020-04-18 22:02:07 +02:00
Ignacio Etcheverry 445f1c6e7b Mono/C#: Add iOS support
Right now, games only work on devices when exported with FullAOT+Interpreter.
There are some issues left that need to addressed for FullAOT alone. Right now,
it's giving issues with the Godot.NativeCalls static constructor.
2020-04-14 18:03:10 +02:00
Ignacio Etcheverry 6b38fe691a Mono/C#: Fix MinGW build not supporting .lib libraries
MinGW should support both its own format `.a` and MSVC's format `.lib`, but Mono's module was only using the former. With this change it's now possible to build with MinGW and link the official Mono for Windows which is built with MSVC.
2020-04-14 18:03:10 +02:00
Hugo Locurcio dd4569f15c Remove syntax highlighting for C# verbatim strings due to bugs
This closes #32336.

(cherry picked from commit 49efd6093e)
2020-04-06 18:18:38 +02:00
Ivan.Shakhov 66e4c8be23 fix RiderPathLocator - searching for toolbox on Mac
(cherry picked from commit dc16b8742a)
2020-04-06 18:15:20 +02:00
Ignacio Etcheverry bda993dd79 C#: Fix uses of old Configuration names
(cherry picked from commit 66c0b7ce98)
2020-04-06 18:14:07 +02:00
Andrii Doroshenko (Xrayez) 8fedcfbed2 Generate command line help text for mono module
(cherry picked from commit 94b6c1363c)
2020-03-25 11:38:54 +01:00
Ivan.Shakhov 9d0518cf80 Fix warning: Property not found: mono/editor/editor_path_optional (#36995)
(cherry picked from commit 05946be2f1)
2020-03-25 11:38:54 +01:00
Ignacio Etcheverry d46fcbb16a C#: Replace uses of old Configuration and update old csprojs
(cherry picked from commit 1b634785b5)
2020-03-25 11:38:54 +01:00
Ivan Shakhov b874e84147 reorder solution configurations + migration
(cherry picked from commit ce01b83c4a)
2020-03-25 11:38:54 +01:00
Ignacio Etcheverry d1a5f8dbf2 [3.2] Sync csproj when files are changed from the Godot FileSystem dock 2020-03-18 17:57:45 +01:00
Phischermen 69c1805735 Added parameters to Load()
(cherry picked from commit 1b0819bd59)
2020-03-06 23:55:25 +01:00
Rémi Verschelde 4c325c0732 Mono: Fix detection of Apple platforms in build script
(cherry picked from commit 5b040ef2e8)
2020-03-06 23:51:26 +01:00
Ivan Shakhov 88f0cd0b27 On Windows find Rider installed for CurrentUser
(cherry picked from commit c95e20a089)
2020-03-04 12:40:15 +01:00
Raul Santos 447acafa97 Fix missing null check in Mono Binding of GD.print
(cherry picked from commit 6b9c22542f)
2020-03-04 12:40:15 +01:00
Ivan Shakhov f0b63b47aa use Rider MSBuild on Windows, when Rider is selected as external editor
(cherry picked from commit a9c2ab81cf)
2020-03-04 12:40:14 +01:00
Ivan Shakhov 8337cc5f7d Support toolbox custom "Tools install location", by reading .settings.json
(cherry picked from commit 33af53c1a6)
2020-03-04 12:40:14 +01:00
Rémi Verschelde 57de8397b2 Fix Mono check for unsafe object references
(cherry picked from commit 09534e2922)
2020-02-14 16:10:06 +01:00
Raul Santos 0fb35401d4 Avoid going out of bounds in IsSubsequenceOf
Closes #35598

(cherry picked from commit 4b79ef5ebe)
2020-02-14 16:03:18 +01:00
Aaron Franke 9a396a4e07 [Mono] Basis/Transforms Array operator comments and improvements
The behavior for Basis and Transform2D is unchanged, and Transform gets new behavior. All of the behavior is identical to GDScript's behavior. 

(cherry picked from commit 0a39c7b354)
2020-02-14 15:53:59 +01:00
Fabián L 04cfcb3ba0 Fixed GetNodeOrNull<T>
GetNodeOrNull<T> was using GetNode instead of GetNodeOrNull

(cherry picked from commit f595486076)
2020-02-06 13:02:07 +01:00
Rémi Verschelde c96f08dc86
Merge pull request #35527 from neikeq/issue-35259
Mono/C#: Fix _update_exports possible crash with Reference types
2020-01-24 21:51:57 +01:00
Rémi Verschelde 75ab07546b
Merge pull request #35524 from neikeq/issue-35496
Fix C# preprocessor infinite loop and incorrect parsing of `#if!`
2020-01-24 21:51:38 +01:00
Ignacio Etcheverry 966a126186 Mono/C#: Fix _update_exports possible crash with Reference types
The code was attempting to dynamic cast the native instance to Reference after
the managed instance was disposed. As the managed instance acts as a Ref,
the native instance was freed during that disposal.
This made the dynamic cast fail and we attempted to memdelete a second time.

The fix is to make the dynamic cast before disposal.
2020-01-24 18:28:40 +01:00
Ignacio Etcheverry 0604b1839d Fix C# preprocessor infinite loop and incorrect parsing of #if! 2020-01-24 17:53:17 +01:00
Rémi Verschelde 55f580b24a
Merge pull request #35491 from neikeq/issue-35450
Mono/C#: Lighten up unsafe reference checks
2020-01-23 23:06:58 +01:00
Ignacio Etcheverry 55b2e58a98 Mono/C#: Lighten up unsafe reference checks
Because of the weird case with multi-threading and ResourceLoader, it can be the case that a resource is GCed while being referenced again in the main thread. In such cases, a new unsafe reference is created before the finalizer thread removes the previous one.
2020-01-23 21:23:32 +01:00
Rémi Verschelde cadf946863
Merge pull request #35478 from neikeq/issue-32260
Mono/C#: Add setting to include I18N assemblies in the exported game
2020-01-23 18:24:15 +01:00
Ignacio Etcheverry 59ec19d5a8 Mono/C#: Add setting to include I18N assemblies in the exported game 2020-01-23 17:47:09 +01:00
Rémi Verschelde b75fff5a56
Merge pull request #35473 from neikeq/default-to-net47
Mono/C#: Default to net47 for new projects
2020-01-23 17:23:33 +01:00
Ignacio Etcheverry 82b0899e54 Mono/C#: Add Basis.Slerp, update Quat.Xform and add some math checks 2020-01-23 16:13:28 +01:00
Ignacio Etcheverry d9ff5f7fc2 Mono/C#: Default to net47 for new projects 2020-01-23 15:57:47 +01:00
Ignacio Etcheverry d53c15b12c Make script class parser errors to not abort the build
As our script class parser is error prone, we should not impede the build from continuing because of a parsing error.
This should be reverted in the future once we switch to Roslyn.
2020-01-21 20:07:26 +01:00
Ignacio Etcheverry 378fc592b1 Add dummy preprocessor for the C# script class parser
No attempts are made at conditional compilation. The main if branch is always assumed to be true.
2020-01-21 19:57:38 +01:00
Ignacio Etcheverry e4330e33e6 Mono/C#: Fix error when parsing nested generics
Also fixed the editor not including the parse error message in the error.
2020-01-20 19:08:08 +01:00
Ignacio Etcheverry a6105c8ea0 Fix ClassDB API portability with some android and editor classes
- `EditorNavigationMeshGenerator` was being registered as part of the Core API,
even after d3f48f88bb. We must make sure to
set Editor as the current ClassDB API type before creating an instance.

- The `VisualScriptEngineSingleton.constant` property has a property hint string
that's different between tools and non-tools builds. This commit makes the
hint string to no longer be set in `_bind_methods`, and to instead set it in
`_validate_property`. This way it's ignored when calculating the API hash.

- `JavaClassWrapper` is now registered in ClassDB on all platforms,
using a dummy implementation on platforms other than Android.
This fixes API portability between Android and other platforms.

- Updated `--class-db-json` command to ignore non-virtual methods that start
with an underscore (see: 4be87c6016).
2020-01-19 20:15:13 +01:00
Ignacio Roldán Etcheverry 1191d26ddc
Merge pull request #35208 from neikeq/mono-lazy-thread-attach
Mono/C#: Script interface calls now attach the current thread
2020-01-16 21:27:08 +01:00
Ignacio Etcheverry d68b9c20d6 Mono/C#: Script interface calls now attach the current thread
Added guards to all C# script interface calls to attach the current thread
for the current scope if the thread is not already attached.
This is far from ideal, as attaching the thread is not cheap and all managed
thread local storage is lost when we detach the thread at the end of the calls.
However, it's the best we can do for now to avoid crashing
when an unattached thread tries to interact with C# code.
2020-01-16 17:47:36 +01:00
Ignacio Etcheverry 1a40f250bd Mono/C#: Fix false positive in unsafe reference checks 2020-01-15 23:46:42 +01:00
Rémi Verschelde 9b8d1383ce Mono: Fix parsing assembly names as UTF-8
Fixes #27185.
2020-01-15 11:51:03 +01:00
Ignacio Etcheverry a6a5ef0fd6 Mono/C#: Add error checks to detect possible Reference leaks 2020-01-13 21:00:07 +01:00
Ignacio Etcheverry ea737db43c Mono/C#: Fix _update_exports() leaking temporary Object/Node instances 2020-01-13 20:58:46 +01:00
dankan1890 51c601d2e3 [Mono]: the C# script icon is now visible in the editor. 2020-01-03 22:49:22 +01:00
Rémi Verschelde 399e53e8c3
Merge pull request #34784 from neikeq/fix-hintpath-godottools
Mono/C#: Fix wrong HintPath for package in GodotTools
2020-01-03 16:34:08 +01:00
Ignacio Etcheverry 9ce0ddcf0d Mono/C#: Fix wrong HintPath for package in GodotTools 2020-01-03 15:53:16 +01:00
Aaron Franke 68ba2588b8
[Mono] Color arithmetic operators 2020-01-03 06:00:14 -05:00
Aaron Franke 0b3f1cc70a
[Mono] Make Sign methods consistent with GDScript and System.Math 2020-01-02 16:41:41 -05:00
Ignacio Etcheverry c1ff3ef9e8 Mono/C#: Fix comment generation for non-constant param default
- Generate the comment for the param, even if the method has no description.
- Generate the comment outside the <summary> element.
2020-01-02 18:10:02 +01:00
Ignacio Etcheverry f3aa793ba3 Mono/C#: Fix bindings generator with void vararg methods
Commit 4d727f1ee6 made it possible for vararg
methods to return void. This broke the C# bindings generator which was
assuming in one place that vararg methods always return Variant.
2020-01-02 18:02:48 +01:00
Ignacio Etcheverry 844a8d215b Mono/C#: Make 'GD.Print' and its variants fallback to 'ToString()'
Up until now, 'GD.Print' would convert parameters first to
Variant and only then to String. This meant parameters that cannot be
converted to Variant would be printed as "Null".
This commit makes 'GD.Print' fallback to 'System.Object.ToString()'
if the parameter could not be converted to Variant.
The same applies to all 'GD.Print' variants:
'GD.PrintS', 'GD.PrintT', 'GD.PrintErr' and 'GD.PrintRaw'.
2020-01-02 13:54:20 +01:00
Ignacio Etcheverry ea75ea50d2 Mono/C#: Fix GD.PrintErr now showing in the Output panel 2020-01-02 13:13:22 +01:00
Rémi Verschelde a7f49ac9a1 Update copyright statements to 2020
Happy new year to the wonderful Godot community!

We're starting a new decade with a well-established, non-profit, free
and open source game engine, and tons of further improvements in the
pipeline from hundreds of contributors.

Godot will keep getting better, and we're looking forward to all the
games that the community will keep developing and releasing with it.
2020-01-01 11:16:22 +01:00
Ignacio Roldán Etcheverry 7fddf5eb7c
Merge pull request #34699 from van800/godot-guid
Custom property for Godot generated project
2019-12-31 20:28:14 +01:00
Rémi Verschelde edf2ed5e50
Merge pull request #34582 from timothyqiu/forward-decl
Cleans up headers included in editor_node.h
2019-12-30 16:28:47 +01:00
Ivan Shakhov af2e6e12d1 add custom property to csproj, which identifies that project is generated by Godot 2019-12-30 16:16:47 +01:00
Dan Kramer 1b26f2c505 Fix msbuild target argument 2019-12-29 17:03:21 -05:00
Ignacio Etcheverry 86274b9fc9 Mono/C#: Re-structure API solution and GodotTools post-build target
Previously we had a placeholder solution called 'Managed' to benefit from
tooling while editing the a part of the C# API.
Later the bindings generator would create the final 'GodotSharp' solution
including these C# files as well as the auto-generated C# API.
Now we replaced the 'Managed' solution with the final 'GodotSharp' solution
which is no longer auto-generated, and the bindings generator only takes
care of the auto-generated C# API.
This has the following benefits:
- It's less confusing as there will no longer be two versions of the same file
(the original and a generated copy of it). Now there's only one.
- We no longer need placeholder for auto-generated API classes, like Node or
Resource. We used them for benefiting from tooling. Now we can just use the
auto-generated API itself.
- Simplifies the build system and bindings generator. Removed lot of code
that is not needed anymore.

Also added a post-build target to the GodotTools project to copy the output to
the data dir. This makes it easy to iterate when doing changes to GodotTools,
as SCons doesn't have to be executed anymore just to copy these new files.
2019-12-28 20:48:55 +01:00
Ignacio Roldán Etcheverry 318c693516
Merge pull request #34595 from van800/mac_rider
Fix search for Rider path on Mac
2019-12-26 02:16:55 +01:00
Ignacio Roldán Etcheverry f90e8c41a2
Merge pull request #34604 from neikeq/issue-27674
Mono/C#: Fix memory leak with new Reference instances created from C#
2019-12-25 20:47:07 +01:00
Ignacio Etcheverry 0ef635c0e3 Mono/C#: Fix memory leak with new Reference instances created from C# 2019-12-25 19:33:59 +01:00
Ivan.Shakhov 682dd04b2d fix Rider path on Mac 2019-12-25 00:14:31 +01:00
Haoyu Qiu 078c0d75f2 Cleans up headers included in editor_node.h 2019-12-24 21:46:05 +08:00
Dan Kramer 097d1c9383 add suggested fix 2019-12-21 13:26:29 -05:00
Rémi Verschelde a10449bbbc
Merge pull request #34514 from neikeq/remove-dep-on-mono-posix
Mono/C#: Remove GodotTools dependency on the Mono.Posix assembly
2019-12-21 17:07:18 +01:00
Ignacio Etcheverry 5a3ccf4f14 Mono/C#: Remove GodotTools dependency on the Mono.Posix assembly
MSBuild on Windows uses the system .NET Framework BCL instead of Mono's. Because
of this, it may not be able to find the Mono.Posix assembly, so it's better
not to depend on it. We needed Mono.Posix to call Syscall.access, so we can
replace this with an internal call that does the same in C++.
2019-12-21 15:55:45 +01:00
Rémi Verschelde 2a4c528d06
Merge pull request #34465 from neikeq/no-hardcode-debugger-wait
Mono/C#: Remove hard-coded debugger wait at initialization
2019-12-19 21:27:59 +01:00
Ignacio Etcheverry f3c6c63b94 Mono/C#: Remove hard-coded debugger wait at initialization
Up until now debug builds would always wait up to 500 ms during initialization
to give time for debuggers to attach to the game.
We no longer want this as it increases startup time unnecesarily.
The way forward is to setup the debugger agent as client instead of server.
This way it's the game that connect to the debugger, not the other way around.
If server mode is still desired, suspend=y can be used to indefinitely wait
for the debugger to attach. This all can be specified with the environment
variable 'GODOT_MONO_DEBUGGER_AGENT' when launching the game.
2019-12-19 17:07:20 +01:00
Ignacio Etcheverry 98dc07f25f Mono/C#: Fix Variant -> MonoString* when type is Variant:NIL
`Variant::operator String()` returns "Null" if the type is `Variant:NIL`.
We must consider that and return a null `MonoString*` instead when marshalling.
This was also causing a "Null" error to be displayed when exporting a game
because null string members would be set to "Null" during hot-reload.
2019-12-19 16:51:32 +01:00
Rémi Verschelde 1c6b9bfdff Mono: Copy native and btls libs on macOS 2019-12-18 08:39:37 +01:00
Ignacio Etcheverry 20d7013c60 Mono/C#: Fix project export and fix FindLast/GetFile regression
d09193b08a introduced a regression in
StringExtensions.FindLast. StringExtensions.GetFile was also affected as it
relies on FindLast. This in turn broke the project exporter as it uses GetFile.
The cause of the regression is that now FindLast is calling LastIndexOf
with 'startIndex: 0'. This should be 'startIndex: str.Length - 1' instead.

Also fixed another regression in the project exporter:
de7c2ad21b moved 'GodotTools/GodotSharpExport.cs'
to 'GodotTools/Export/ExportPlugin.cs' and in doing so accidently reverted
the changes from commit e439581198.
2019-12-17 13:06:41 +01:00
Rémi Verschelde c3ea4ea9b7
Merge pull request #34382 from van800/profiler
Allow attaching any external profiler, including JetBrains dotTrace
2019-12-16 22:00:36 +01:00
Ivan Shakhov 7c64779516 Allow attaching any external profiler, including JetBrains dotTrace 2019-12-16 20:34:30 +01:00
Rémi Verschelde a866028a7a Mono: Enable threads suspend workaround on Windows
This appears to be necessary for current official builds cross-compiled
with MinGW from Linux, using Mono 6.6.0.160.

Follow-up to #31784, see #29812 for details.
2019-12-16 15:40:26 +01:00
Rémi Verschelde 12ee35737f
Merge pull request #34334 from neikeq/issue-33503
Mono/C#: Fix class parser bug with 'where T : struct'
2019-12-13 20:13:28 +01:00
Ignacio Etcheverry f2a2293709 Mono/C#: Fix class parser incorrectly handling nested namespaces
It would incorrectly error thinking the nested namespace is being declared inside a struct/class. This was because of an incorrect nesting level being used for classes and structs.
2019-12-13 19:55:32 +01:00
Ignacio Etcheverry c1ab956dd0 Mono/C#: Fix class parser bug with 'where T : struct'
The struct decl parsing was outdated. Make both struct decl and class declparsing share the same code.
2019-12-13 19:50:42 +01:00
Rémi Verschelde 9f68626fb2 doc: Sync classref with current source
Also apply clang-format.
2019-12-13 10:41:06 +01:00
Rémi Verschelde d39284a65f
Merge pull request #34295 from aaronfranke/potato-knishes
[Mono] Fix string Find methods having reversed case sensitivity
2019-12-13 08:47:26 +01:00
Aaron Franke d09193b08a
Fix string Find methods having reversed case sensitivity 2019-12-12 02:21:16 -05:00
Aaron Franke 5771f9959c
Mono formatting
No space for casting, add spaces inside braces, 4 space indentation, remove trailing indentation, remove BOM.
2019-12-11 16:32:47 -05:00
Rémi Verschelde cd9d513285
Merge pull request #34181 from van800/rider
Support Rider as external editor for Godot mono version
2019-12-11 09:20:31 +01:00
Ivan Shakhov 8fbc9d33fd Support Rider as External Editor 2019-12-11 08:39:04 +01:00
Jonas 11258db001
Fix missing null checks in Mono Binding of GD
The print methods of mono binding was missing null checks for the params
2019-12-06 11:56:50 +01:00
Ignacio Roldán Etcheverry 6544a0e908
Merge pull request #34018 from dsge/show-template-directory-path-in-error-message
Make sure to include the path in the "Data template directory not found" error message
2019-12-05 14:17:23 +01:00
Ignacio Etcheverry 066ae9d83b Mono/C#: Several android fixes
- Added correct config file for android dllmaps.
- Fix __Internal DllImports with a dlopen fallback.
- Add missing P/Invoke functions and internal calls expected by the monodroid BCL and our custom version of the 'Android.Runtime.AndroidEnvironment' class (this last one can be found in the godot-mono-builds repo).
- Make sure to set 'btls' instead of 'legacy' as the default TLS provider on Android.
2019-12-04 19:03:42 +01:00
Ignacio Etcheverry 3797f19926 C#: Add Duplicate method to the Array and Dictionary bindings 2019-12-04 15:22:30 +01:00
dsge 81cae314b4 Make sure to include the path in the "Data template directory not found" error message 2019-11-30 15:44:18 +01:00
Rémi Verschelde fa0e682027
Merge pull request #33982 from neikeq/issue-29349
Mono/C#: Add option to export assemblies outside of PCK
2019-11-29 11:37:18 +01:00
Ignacio Etcheverry 85d8c42763 Mono/C#: Fix crash on exported games that don't use C# 2019-11-29 01:35:46 +01:00
Ignacio Etcheverry 66de28eda8 Mono/C#: Add option to export assemblies outside of PCK
When using this options, assemblies will be saved in the Assemblies folder of the  data directory: 'data_AppName/Assemblies/'.
2019-11-29 00:36:05 +01:00
Rémi Verschelde 636bc5c32f
Merge pull request #33828 from neikeq/貴様
Mono/C#: Prevent SCons from building API solutions in parallel
2019-11-23 11:24:48 +01:00
Ignacio Etcheverry ebdd2bc474 Mono/C#: Prevent SCons from building API solutions in parallel 2019-11-22 23:42:24 +01:00
Rémi Verschelde c41c24562d Style: Add missing copyright headers 2019-11-22 08:37:09 +01:00
Ignacio Roldán Etcheverry 63b321dbbb
Merge pull request #33791 from neikeq/issue-33761
C#: Fix PathWhich on Windows when name already has extension
2019-11-21 21:34:12 +01:00
Ignacio Etcheverry f91416d9ac C#: Fix PathWhich on Windows when name already has extension
Also make the Posix version of PathWhich check if the file has executable access.
2019-11-21 14:53:00 +01:00
Rémi Verschelde 73323a2838
Merge pull request #33763 from neikeq/issue-33725
Fix C# export error dialog showing up when it should not
2019-11-20 13:23:20 +01:00
Ignacio Etcheverry d79aeca599 Fix C# export error dialog showing up when it should not 2019-11-20 13:07:26 +01:00
Ignacio Etcheverry 3f247ea507 Mono/C#: Bundle libmono-btls-shared.dll on Windows if it exists 2019-11-19 17:22:06 +01:00
Ignacio Etcheverry 008769aee9 C#: Throw NullReferenceException for null NodePath/RID params 2019-11-18 12:23:54 +01:00
Ignacio Etcheverry 8cbe4a3db4 Make C# internal calls return structs as ref parameters
The Mono IL interpreter's WebAssembly to native trampolines don't support passing structs by value, so we need to do it this way.

Also now we pass and return long, ulong, float and double as ref parameters as well. This is due to missing trampolines for float and long types. This is likely a temporary workaround that will be reverted in the future. The correct solution would be to patch 'mono/mini/m2n-gen.cs' when building the Mono runtime for WASM in order to generate the trampolines we need.
2019-11-15 03:22:25 +01:00
Ignacio Etcheverry 2b67924a0b Mono/C#: Initial exporter support for AOT compilation 2019-11-15 03:22:18 +01:00
Ignacio Etcheverry de7c2ad21b Mono/C#: WebAssembly support 2019-11-13 21:41:11 +01:00
Ignacio Roldán Etcheverry 953f37f49b
Merge pull request #33249 from JoshLee0915/MonoHeadlessServer
Added missing server platform checks to template dir and shared lib copy in mono_configure.py
2019-11-12 14:57:29 +01:00
Rémi Verschelde 77816fea8b
Merge pull request #32477 from aaronfranke/equal-approx-separate
Make is_equal_approx separate and make == exact again
2019-11-07 14:54:15 +01:00
Aaron Franke 4922a48a9e
[Mono] Alphabetize Mathf 2019-10-29 10:10:24 -04:00
Rémi Verschelde e96319c7f3
Merge pull request #32670 from aaronfranke/mono-plane
[Mono] Change Plane intersect methods to return nullable Vector3
2019-10-23 21:44:05 +02:00
JoshLee0915 cbd98d0fcf Added the server platform checks to template dir and shared lib copy 2019-10-21 20:47:24 -06:00
Aaron Franke 218f38c7ec
Expose is_equal_approx and restore == to be exact again
This commit changes behavior for GDScript and C#.

Also did some organizing of the order to logically group related methods, mostly for Rect2 and AABB.
2019-10-14 16:48:59 -04:00
Aaron Franke 86922ff70b
Make is_equal_approx separate for structures
This commit adds exposed behavior for C#
2019-10-14 16:46:54 -04:00
Ignacio Etcheverry 8a0c0371d4 C#: Fix regression from #32732 caused a crash on domain reload 2019-10-12 21:27:56 +02:00
Rémi Verschelde 3cc94b2c0b Mono: Fix template build after #32732 2019-10-11 15:17:36 +02:00
Ignacio Etcheverry 8c438a2197 C#: Fix detection of outdated release Godot API assemblies 2019-10-11 01:46:06 +02:00
Aaron Franke 643874f8ca
[Mono] Change Plane intersect methods to return nullable Vector3 2019-10-08 22:47:22 -04:00
Rémi Verschelde f3f2fdfbab Mono: Fix detection of MsBuild from Visual Studio
This was a wrong check as an exit code of 0 means success,
not failure. It used to be fine as blocking mode always returned
-2, but this was changed in #32033 to return the exit code.

Fixes #32424.
2019-10-03 14:13:41 +02:00
Ignacio Roldán Etcheverry 763a4d8402
Merge pull request #32401 from neikeq/Kisaama!
Mono: Don't compare API hashes on release builds
2019-09-28 03:31:37 +02:00
Ignacio Etcheverry 1509890dbc Mono: Don't compare API hashes on release builds
API hashes cannot be calculated on release builds, as bindings information is lacking. Therefore, we should not be comparing it with the generated glue hash as they will never match.
2019-09-28 01:07:57 +02:00
Rémi Verschelde e067a54988
Merge pull request #32353 from neikeq/yamero
Mono: Improve API assembly load error message on exported games
2019-09-26 07:31:03 +02:00
Rémi Verschelde 0a10e07124
Merge pull request #32352 from neikeq/issue-32237
Mono: Don't use project settings for debugger agent on exported games
2019-09-26 07:29:25 +02:00
Ignacio Etcheverry 2325fb11a8 Mono: Improve API assembly load error message on exported games 2019-09-25 22:32:39 +02:00
Ignacio Etcheverry 5ff4e0516b Mono: Don't use project settings for debugger agent on exported games 2019-09-25 22:03:24 +02:00
Rémi Verschelde dec10dd776
Merge pull request #32051 from qarmin/some_error_explanation
Added some obvious errors explanations
2019-09-25 11:51:54 +02:00
qarmin 17732fe698 Added some obvious errors explanations 2019-09-25 10:28:50 +02:00
Ignacio Etcheverry c4fa027614 Improve C# bindings generator errors for default param values 2019-09-24 15:09:54 +02:00
Rémi Verschelde 9c116f4f1d
Merge pull request #32223 from neikeq/cs_glue_version_fix
C#: Make sure cs_glue_version is present when building export templates
2019-09-20 17:46:34 +02:00
Ignacio Etcheverry 95c685143a C#: Make sure cs_glue_version is present when building export templates 2019-09-20 17:41:20 +02:00
Rémi Verschelde f9db6ad8c5
Merge pull request #31919 from m4gr3d/use_aar_for_custom_build
Leverage Android archive (AAR) file for Godot custom build
2019-09-19 20:22:09 +02:00
Chaosus89 46bb523db7 [Mono] Corrected rectangle intersection 2019-09-16 09:49:04 +03:00
Rémi Verschelde 24e1039eb6
Merge pull request #32045 from neikeq/fix-cannot-create-mono-log-file
Mono: Fix unable to create log file due to str_format bug
2019-09-08 22:31:52 +02:00
Ignacio Etcheverry 3dcd7e54f4 Mono: Fix unable to create log file due to str_format bug 2019-09-08 19:40:17 +02:00
Ignacio Roldán Etcheverry da2af72d73
Merge pull request #32022 from neikeq/fix-mono-export-windows-backslash
Mono: Fix PCK assembly paths when exporting from Windows
2019-09-07 21:39:27 +02:00
Ignacio Etcheverry 93897fb884 Fix missing method for internal_MonoWindowsInstallRoot 2019-09-07 02:31:01 +02:00
Ignacio Etcheverry e439581198 Mono: Fix PCK assembly paths when exporting from Windows
Assembly paths were written to PCK files with backslash as path separator and PackedData only supports forward slash.
This would make exported games unable to find the assemblies.
2019-09-07 02:19:25 +02:00
fhuya 7fabfd402f Split the Android platform java logic into an Android library module (lib) and an application module (app).
The application module `app` serves double duties of providing the prebuilt Godot binaries ('android_debug.apk', 'android_release.apk') and the Godot custom build template ('android_source.zip').
2019-09-04 16:20:22 -07:00
iwek7 617797c47c Adds skip-breakpoints feature 2019-09-03 20:49:09 +02:00
Aaron Franke f8b4cf0fc4
Check for exact equality before approximate equality 2019-09-01 14:02:14 -04:00
Ignacio Etcheverry 5a6070dde3 Mono: Force preemptive thread suspend mode as a temporary workaround 2019-08-30 01:33:50 +02:00
Rémi Verschelde a5e0aa32d9
Merge pull request #31770 from neikeq/supercedes-31008
Fix GodotTools.ProjectEditor HintPaths for referenced packages
2019-08-29 21:16:49 +02:00
Ignacio Etcheverry 6d2883c9bf Fix GodotTools.ProjectEditor HintPaths for referenced packages 2019-08-29 18:19:01 +02:00
Rémi Verschelde 65d1b0b427
Merge pull request #31729 from aaronfranke/mono-color
[Mono] Various Color fixes and improvements
2019-08-28 21:29:47 +02:00
Rémi Verschelde 538328898b Style: Fix copyright headers in new files 2019-08-28 09:19:52 +02:00
Rémi Verschelde 185072015f
Merge pull request #31606 from toasteater/fix/nativescript-new-json-return-type
Fix the return type of NativeScript::new in API json
2019-08-28 09:15:40 +02:00
Aaron Franke 34ab6549b1
[Mono] Various Color improvements
I also slid in a fix to C++ Vector3 > and >=
2019-08-27 22:05:18 -04:00
Rémi Verschelde 92ead83913 Mono: Fix OSX build due to invalid function call 2019-08-27 09:48:54 +02:00
toasteater e2121c97ae Make VarArg methods return types show up as Variant in API json
VarArg methods have the return type Object in the API json for GDNative. This
can cause undefined behavior in some language bindings due to lack of
documentation on VarArg methods' behavior.

This changes the MethodInfo of:

- CSharpScript::_new
- GDScript::_new
- PluginScript::_new
2019-08-26 16:36:51 +00:00
Ignacio Roldán Etcheverry be99e7b68f
Merge pull request #31680 from neikeq/fix-android-gen-sources
Fix 'android_mono_config.gen.cpp' not compiled first time it's generated
2019-08-26 18:28:12 +02:00
Ignacio Etcheverry aa805e2699 Fix 'android_mono_config.gen.cpp' not compiled first time it's generated 2019-08-26 17:46:57 +02:00