Commit graph

2235 commits

Author SHA1 Message Date
Rémi Verschelde
a64cb8eff3
Merge pull request #88570 from paulloz/dotnet/warnings-editorconfig-cleanup
[.NET] Better `.editorconfig` setup in `modules/mono/`
2024-02-27 21:23:03 +01:00
Paul Joannon
139a5df821
Cleanup C# projects, code quality & style
New rules:
- Do not silence CA1805 any more
- Limit where we silence CA1707, CA1711, CA1720
- Enforce severity=warning for IDE0040
- Enforce Allman style braces
- Enforce naming conventions (IDE1006 is still severity=suggestion)

Fixes:
- Fix REFL045, CS1572, CS1573
- Suppress CS0618 when generating `InvokeGodotClassMethod`
- Fix indent when generating GD_constants.cs
- Temporarily silence CS1734 in generated code
- Fix a lot of naming rule violations

Misc.:
- Remove ReSharper comments for RedundantNameQualifier
- Remove suppression attributes for RedundantNameQualifier
- Remove severity=warnings for CA1716, CA1304 (already included in the level of analysis we run)
2024-02-27 20:11:24 +01:00
Thaddeus Crews
be7019de0f
C#: Only check for empty deprecation message if deprecated 2024-02-27 10:22:32 -06:00
emre0altan
4100a23c5e Clarify C# Color opacity comment 2024-02-27 15:56:21 +00:00
Rémi Verschelde
730ef374b4
Merge pull request #88652 from RobProductions/fix-hover-margin
Fix editor hover style margins when Draw Extra Borders is enabled
2024-02-27 10:17:34 +01:00
Pedro J. Estébanez
5e144022e7 Enhance cache modes in resource loading
- Unify documentation, hoping to clear misconcepctions about about propagation of the cache mode across dependant loads.
- Clarify in docs that `CACHE_MODE_REPLACE` now also works on the main resource (from #87008).
- Add two recursive modes, counterparts of `CACHE_MODE_REPLACE` and `CACHE_MODE_IGNORE`, since it seems some need them (see #59669, #82830).
- Let resources, even loaded with one of the ignore-cache modes, get a path, which is useful for tools.
2024-02-26 14:59:04 +01:00
Rémi Verschelde
762ea7a0b2
Merge pull request #88730 from raulsntos/dotnet/deprecated-message
C#: Add deprecated message to generated bindings
2024-02-26 10:49:05 +01:00
Rémi Verschelde
5059dd91f3
Merge pull request #88692 from nongvantinh/fix-88543
Fix Script Editor saves C# files as embedded scripts.
2024-02-26 10:49:01 +01:00
Rémi Verschelde
9509a9e8dd
Merge pull request #83691 from theraot/slidedocs
Expanded documentation for vector slide and project
2024-02-26 10:48:37 +01:00
Nông Văn Tình
c5e6a5863d Fix Script Editor saves C# files as embedded scripts
fixes: #88543
fixes: #88160

Because of the limitations of compiled programming languages like C#, when a newly created *.cs file hasn't been compiled, we don't have any information about its `Path` or `Type` in the `assemply`. This means we end up creating an invalid instance of this file whenever there's a request. Consequently, multiple instances of the script can exist. When a new instance takes over the path, it clears the `path_cache` of the previous instance, leading to undefined behavior.
2024-02-25 22:08:18 +07:00
Raul Santos
40b7dd0cf3
C#: Add deprecated message to generated bindings
Uses the `DocData` deprecated message in the C# `[Obsolete]` attribute added to deprecated members.
2024-02-23 20:30:36 +01:00
Raul Santos
5ba92e5a57
Fix some DEFVALs to use the right type
- Use `StringName()` in DEFVAL for StringNames.
- Use `Variant()` in DEFVAL for Variants.
2024-02-23 01:50:18 +01:00
Matt Enad
f75cffcd46 Fix hover style margin with extra borders enabled
The content margins for FlatMenuButton and RunBarButton are now handled correctly when the "Draw Extra Borders" user option is enabled
2024-02-21 21:36:48 -05:00
Rémi Verschelde
c6d091e0f3
Merge pull request #87253 from van800/van800/analyser
Provide a roslyn analyzers corresponding to the GD0001 and GD0002
2024-02-21 15:22:54 +01:00
Ivan Shakhov
00dc19585b provide analyser corresponding to the GD0001 and GD0002, add ClassPartialModifierAnalyzerFix, and tests
Co-authored-by: Raul Santos <raulsntos@gmail.com>
Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com>
2024-02-21 12:35:28 +03:00
Rémi Verschelde
aeaec000fc
Merge pull request #88495 from paulloz/dotnet/test-and-fix-exports-diagnostics
[.NET] Test and fix exports diagnostics
2024-02-21 07:43:08 +01:00
Rémi Verschelde
00f6c97610
Merge pull request #80343 from raulsntos/dotnet/warnings/RS2008
C#: Add analyzer release tracking
2024-02-20 23:59:39 +01:00
Rémi Verschelde
1aab6e96b9
Merge pull request #87133 from Repiteo/dotnet/enforce-globalization-rules
C#: Enforce globalization code quality rules
2024-02-20 20:04:30 +01:00
Rémi Verschelde
9e9dcdbba4
Merge pull request #86378 from RobProductions/update-hover-styling
Add hover highlight to main editor buttons
2024-02-20 19:34:40 +01:00
Thaddeus Crews
000d12d237
C#: Enforce Globalization code quality rules 2024-02-20 11:15:12 -06:00
Paul Joannon
88ad4e6c24
Add tests and fix exports diagnostics
- Add tests for the following diagnostics: GD0101, GD0102, GD0103, GD0104, GD0105, GD0106, GD0107.
- Fix GD0101 not being reported any more (was filtering static classes before reporting).
- Fix GD0107 not preventing `Node` members from being exported from not-`Node` types.
2024-02-20 11:24:41 +01:00
Raul Santos
f685c69bd4
C#: Add analyzer release tracking
Fixes diagnostic RS2008.
2024-02-19 19:47:40 +01:00
Ivan Shakhov
703c34a788 Bump Rider.PathLocator nuget version, which provides a fix for detecting Rider installations 2024-02-19 21:04:28 +03:00
Raul Santos
fe280ef9ae
C#: Various fixes to generic scripts
- Report a diagnostic when there are multiple classes that match the script file name in the same script since that will result in a duplicate path key in the bimap and it's not allowed.
- Fix InspectorPlugin to handle empty paths in case the project was built with a previous version of Godot that used empty paths for generic scripts.
- Add tests for the new diagnostic GD0003.
2024-02-19 06:33:13 +01:00
Rémi Verschelde
9f48330c3f
Merge pull request #88469 from paulloz/dotnet/cleaner-diagnostic-rules
[.NET] Clean diagnostic rules
2024-02-19 00:08:30 +01:00
Rémi Verschelde
033821c595
Merge pull request #88245 from shana/simplify-mono-support-detection
C#: Let platforms signal if they support the mono module or not
2024-02-19 00:08:07 +01:00
Paul Joannon
5981886fb7
Clean diagnostic rules
Move the following diagnostics into static readonly fields: GD0101, GD0102, GD0103, GD0104, GD0105, GD0106, GD0107, GD0201, GD0202, GD0203, GD0301, GD0302, GD0303, GD0401, GD0402.

To be more consistent, the titles for the following diagnostics were modified: GD0101, GD0105, GD0106, GD0302, GD0303, GD0401, GD0402. A subsequent update of the documentation repo is needed.

Tests for the following diagnostics were created: GD0201, GD0202, GD0203.
2024-02-18 16:47:20 +01:00
Raul Santos
dcb411daee
C#: Fix building OpenVisualStudio executable
Since moving the TFM to .NET Core we need to add some configuration to cross-compile a Windows executable from Linux.
2024-02-18 05:40:06 +01:00
Thaddeus Crews
48428bd087
C#: Match Core implementation of BinToInt & HexToInt 2024-02-17 11:59:14 -06:00
Rémi Verschelde
ccd9cefa8e
Merge pull request #87137 from /dotnet/nullable-godot-tools 2024-02-17 18:31:37 +01:00
Matt Enad
5b5de0e167 Add hover highlight to main editor buttons
Updates styling of the editor run bar, plugin, bottom panel, icon buttons, and main menu buttons for accessibility.
2024-02-16 14:49:44 -05:00
Rémi Verschelde
09df8f4a56
Merge pull request #87952 from paulloz/dotnet/byebye-signal-callback-generation
Disable signal callback generation in C#
2024-02-15 15:44:55 +01:00
Rémi Verschelde
1efc3625fa
Merge pull request #87342 from raulsntos/dotnet/warnings/RS1024
C#: Use SymbolEqualityComparer
2024-02-15 15:44:47 +01:00
Raul Santos
7b348708e8
C#: Use SymbolEqualityComparer
Use `SymbolEqualityComparer` to compare symbols and fix `RS1024` warning.
2024-02-14 17:33:06 +01:00
Muller-Castro
a8bc9f3e78 Add const lvalue ref to core/* container parameters 2024-02-14 11:20:36 -03:00
Paul Joannon
9fa2355cef
Disable signal callback generation in C# 2024-02-14 13:26:45 +01:00
Andreia Gaita
21e524a798 C#: Let platforms signal if they support it or not
Instead of hardcoding platform names that support C#, let platforms
set a flag indicating if they support it. All public platforms
except web already support it, and it's a pain to maintain a patch
for this list just to add additional names of proprietary console
platforms.

This makes adding new platforms or variants or existing platforms
much easier, as the platform can signal what it supports/doesn't
support directly, and we can avoid harcoding platform names.
2024-02-13 22:48:43 +01:00
Thaddeus Crews
3314f8cc65
C#: Enable nullable environment for GodotTools 2024-02-13 12:24:53 -06:00
Rémi Verschelde
dfe226b933
Merge pull request #88270 from TokageItLab/avoid-near-far
Avoid unqualified-id "near" and "far" in Node3DEditor/Viewport
2024-02-13 11:25:24 +01:00
Silc Lizard (Tokage) Renew
67e38709fd Avoid unqualified-id "near" and "far" in Node3DEditor/Viewport 2024-02-13 18:53:21 +09:00
Zae
8245157682 C#: Fix missing CowData 64-bit promotion for PackedInt32Array. 2024-02-13 12:19:48 +08:00
Rémi Verschelde
7d89f557f3
Merge pull request #88238 from shana/cs-export-fix-output-files
C#: Fix processing exclusions during export
2024-02-12 23:29:47 +01:00
Andreia Gaita
2f10f7bed4 Fix processing exclusions during export 2024-02-12 11:51:05 +01:00
Raul Santos
5815d1c8c8
Improve handling of generic C# types
- Create CSharpScript for generic C# types.
  - `ScriptPathAttributeGenerator` registers the path for the generic type definition.
  - `ScriptManagerBridge` lookup uses the generic type definition that was registered by the generator.
  - Constructed generic types use a virtual `csharp://` path so they can be registered in the map and loaded as if there was a different file for each constructed type, even though they all share the same real path.
  - This allows getting the base type for a C# type that derives from a generic type.
- Shows base scripts in the _Add Node_ and _Create Resource_ dialogs even when they are generic types.
  - `get_global_class_name` implementation was moved to C# and now always returns the base type even if the script is not a global class (this behavior matches GDScript).
- Create `CSharpScript::TypeInfo` struct to hold all the type information about the C# type that corresponds to the `CSharpScript`, and use it as the parameter in `UpdateScriptClassInfo` to avoid adding more parameters.
2024-02-08 18:31:13 +01:00
Paul Joannon
9d283063a0
Fix C# "out of sync" notice with external editors
Change what triggers our re-evaluation of the last valid build datetime stored internally.
Move that datetime in `BuildManager`.
2024-02-07 21:26:32 +01:00
Raul Santos
8ce4a0cf15
C#: Fix crash when reloading scripts
The crash cond was accidentally moved to the `reload_scripts` method when it was only meant to be in the `reload_tool_script` method. Same about restarting the HotReloadAssemblyWatcher timer.

Also removed the loop that checks if the script array contains a C# script because if we're in CSharpLanguage we can assume that at least one of them is.
2024-02-07 06:33:51 +01:00
Rémi Verschelde
acde2a81ff
Merge pull request #84640 from aaronfranke/gravity-get
Expose a method to get gravity for any physics body
2024-02-05 14:48:31 +01:00
Rémi Verschelde
d0f8b76ffd
Merge pull request #87838 from paulloz/dotnet/fix-duplicate-key-on-reload
C#: Fix duplicate key issue on reload
2024-02-02 12:05:14 +01:00
Rémi Verschelde
8a47d6eb50
Merge pull request #87790 from nongvantinh/fix-87643
Fix incorrect condition for error filtering
2024-02-02 12:03:59 +01:00
Rémi Verschelde
24a2560d30
Merge pull request #87682 from zaevi/fix_csharp_stringname_ref
C#: Fix issues for StringName reference in `CSharpInstanceBridge.Get`.
2024-02-02 12:02:44 +01:00
Paul Joannon
999180d5b5
Delay fs update when populating path bimap 2024-02-01 22:06:40 +01:00
Nông Văn Tình
d81c9c32c5 Fix incorrect condition for error filtering
Fixes: #87643

The original condition stopped immediately after checking for 'searchText' in the 'Message' field, resulting in premature termination of subsequent checks. This fix ensures that all relevant conditions are appropriately evaluated before determining the filtering outcome.

Additionally, accompanying changes include improved code readability for better comprehension. This adjustment enhances the maintainability of the error filtering mechanism, contributing to a more robust codebase overall.
2024-01-31 23:01:37 +07:00
Aaron Franke
aed5ea9460
Expose a method to get gravity for any physics body 2024-01-30 23:57:38 -06:00
Rémi Verschelde
736696b533
Merge pull request #87679 from raulsntos/dotnet/remove-unused
C#: Remove unused code
2024-01-30 17:48:07 +01:00
Michael Wörner
9d50a486bf Fixed ~CSharpScript() holding on to a mutex longer than necessary, creating potential for a deadlock. 2024-01-28 21:28:14 +01:00
Zae
1e14503715 C#: Fix issues for StringName reference in CSharpInstanceBridge.Get. 2024-01-29 02:04:02 +08:00
Raul Santos
82380ec700
C#: Remove unused code
- Remove `AotBuilder` that was used for MonoAOT in 3.x.
- Remove `PlaySettings` that was used for IDE support in 3.x.
- Remove `ApiAssembliesInfo` that was used for Project generation in 3.x.
- Remove pieces of the old iOS support from 3.x.
2024-01-28 16:09:59 +01:00
Rémi Verschelde
99ac3d332a
Merge pull request #87597 from zaevi/fix_csharp_aot_initialization
C#: Fix not assigning `runtime_initialized` when initializing with AOT.
2024-01-26 11:49:53 +01:00
Rémi Verschelde
3bbf4abfaa
Merge pull request #87550 from zaevi/fix_csharp_generic_reloading
C#: Fix sorting for generic types when reloading assemblies.
2024-01-26 11:48:18 +01:00
Rémi Verschelde
563e385810
Merge pull request #87526 from zaevi/fix_csharp_gc
C#: Fix incorrect GC handle for non-instantiable types.
2024-01-26 11:47:25 +01:00
Rémi Verschelde
85b2c947b2
Merge pull request #87518 from paulloz/dotnet/fix-warnings
Clean a number of C# warnings
2024-01-26 11:46:37 +01:00
Rémi Verschelde
849b69828b
Merge pull request #85908 from avilches/fix-must-be-variant-analyzer-fail-with-generic-typed-attributes
Allow using `[MustBeVariant]` in generic typed attributes
2024-01-26 11:42:34 +01:00
Rémi Verschelde
d36f5cf2ba
Merge pull request #85504 from nongvantinh/fix-csharp-loader
Fix C# script loader does not work reliably
2024-01-26 11:42:01 +01:00
Zae
18599c0935 C#: Fix sorting for generic types when reloading assemblies. 2024-01-26 18:00:46 +08:00
Paul Joannon
46b3096570
Clean a bunch of C# warnings
- `[Obsolete]` tag generated in the middle of documentation comments
- Potential `null` values in generators
- Obsolete call to `GetEditorInterface()`
- We don't want `Godot.Collections.Array` to end with `Collection`
- A few culture specifications and use of `AsSpan` instead of `SubString` in `StringExtensions`
- Disable CA1716 in GodotSharp
2024-01-26 09:38:33 +01:00
Zae
e868a9f577 C#: Fix not assigning runtime_initialized when initializing with AOT. 2024-01-26 05:44:40 +08:00
Zae
201e946741 C#: Fix incorrect GC handle for non-instantiable types. 2024-01-25 02:40:08 +08:00
Alberto Vilches
692412562d C#: Fix to allow usage of [MustBeVariant] in generic typed attributes 2024-01-21 22:29:29 +01:00
Nông Văn Tình
7676e389a7 Fixes C# script loader does not work reliably 2024-01-22 04:20:27 +07:00
Rémi Verschelde
0bcc0e92b3
Merge pull request #86730 from reduz/64-bit-cowdata
Promote CowData to 64 bits
2024-01-19 18:46:11 +01:00
Juan Linietsky
24fe0715b5 Promote CowData to 64 bits
Fixes a lot of bugs, please help me fill the list.
2024-01-19 17:41:10 +01:00
Yuri Sizov
b6a2c78033 Merge pull request #87286 from akien-mga/fix-preprocessor-if-ENABLED-checks
Fix `#if *_ENABLED` inconsistencies, should check if defined
2024-01-17 18:53:33 +01:00
Yuri Sizov
66736398cd Merge pull request #87264 from AThousandShips/aabb_fix_cs
[C#] Fix `Encloses` failing on shared upper bound for `AABB` and `Rect2(I)`
2024-01-17 18:53:22 +01:00
Yuri Sizov
c027aecc2e Merge pull request #86676 from rune-scape/sparse-script-reload
GDScript: Hot-reload changed scripts only
2024-01-17 18:52:54 +01:00
Yuri Sizov
7351b5704a Merge pull request #86528 from avilches/must-be-variant-tests
Add unit tests for C# diagnostic analyzers
2024-01-17 18:52:45 +01:00
Rémi Verschelde
0a7579b161
Fix #if *_ENABLED inconsistencies, should check if defined
Co-authored-by: Caroline Joy Bell <halotroop2288@proton.me>
2024-01-17 10:30:15 +01:00
A Thousand Ships
227a165ce4
[C#] Fix Encloses failing on shared upper bound for AABB and
`Rect2(I)`
2024-01-16 20:20:53 +01:00
Yuri Sizov
95b27fe8c7 Reorganize code related to editor theming
This change introduces a new EditorThemeManager class
to abstract theme generatio and its subroutines.

Logic related to EditorTheme, EditorColorMap, and editor
icons has been extracted into their respective files with
includes cleaned up.

All related files have been moved to a separate folder to
better scope them in the project. This includes relevant
generated files as well.
2024-01-16 11:57:45 +01:00
Alberto Vilches
7a90c56c00 C# Add test suite for Diagnostic Analyzers: GlobalClass and MustBeVariant 2024-01-15 11:31:12 +01:00
Rémi Verschelde
3dcf9059ae
Merge pull request #86454 from Repiteo/c#-upgrade-TFMs
C#: Upgrade TFM for `net472` and some `netstandard2.0` projects
2024-01-11 17:37:19 +01:00
Rémi Verschelde
ba96dbb49a
Merge pull request #85460 from van800/master
Bump the `JetBrains.Rider.PathLocator` PackageReference to 1.0.8
2024-01-11 17:36:04 +01:00
Rémi Verschelde
cea56336b2
Merge pull request #86972 from zaevi/fix_csharp_method_return_type
C#: Fix return type hint for methods.
2024-01-10 12:03:33 +01:00
Rémi Verschelde
8a6debd71e
Merge pull request #86592 from emklasson/fix_gd0103_link
Fix typo in GD0103 error link
2024-01-10 12:03:29 +01:00
Zae
51c54b03d1 C#: Fix return type hint for methods. 2024-01-09 04:28:17 +08:00
Thaddeus Crews
7a06390552
C#: Upgrade TFM for net472 and some netstandard2.0 projects 2024-01-06 09:14:33 -06:00
Muller-Castro
96a95cb974 Add const lvalue ref to container parameters 2024-01-05 14:49:57 -03:00
Rémi Verschelde
11d1844e66
Merge pull request #85869 from paulloz/dotnet-warning-out-of-date-properties
.NET: Add a warning in the inspector when properties might be out of sync
2024-01-03 15:43:41 +01:00
Rémi Verschelde
22e880ad20
Merge pull request #83163 from Chubercik/vectorXi_dist_methods
Implement `Vector2i/3i/4i` methods: `distance_to` and `distance_squared_to`
2024-01-03 09:58:36 +01:00
rune-scape
cde478bda6 Hot-reload only changed scripts 2024-01-02 17:56:52 -08:00
Mikael Klasson
a2b183067c fix: use correct number in GD0103 link 2023-12-27 20:30:59 +09:00
Paul Joannon
0818d015db
Inspector ⚠️ when C# props might be out of date 2023-12-22 23:27:13 +01:00
Raul Santos
abd7927325
C#: Use string literal instead of nameof
Using `nameof` expressions with method parameters requires C# 11 and we're currently on C# 10.
2023-12-21 03:11:47 +01:00
Yuri Sizov
ef79e5d9dd Merge pull request #82983 from Repiteo/c#-godotsharp-nullable-classes
[C#] Enable nullability for variant classes
2023-12-19 20:32:30 +01:00
Yuri Sizov
c8d0325a93 Merge pull request #82955 from paulloz/testing-source-generators
Add unit tests for C# source generators
2023-12-19 20:32:26 +01:00
msreis
f1cc14d525 Fix missing time for some script functions in profiler
Fixes the issue by adding a mechanism by which the functions that were
previously disappearing can be profiled too. This is optional with
an editor setting, since collecting more information naturally slows the engine
further while profiling.

Fixes #23715, #40251, #29049
2023-12-19 19:42:21 +01:00
Paul Joannon
b352bdc8cb
Add tests for source generators
- Bootstrap xUnit project to test source generators
- Implement source generator tests
- Better tests structure (put test data in cs files)
- Enable `ScriptSerializationGeneratorTests`
- Enable `ScriptPathAttributeGeneratorTests`
- Fix `NesterClass` -> `NestedClass`
- Use `Path.Combine` when dealing with paths
- Copy test data to the output directory
2023-12-19 18:26:52 +01:00
Yuri Sizov
f478a599fc Merge pull request #85975 from Repiteo/c#-null-ptr-exception
C#: Implement function to throw on null pointers
2023-12-19 13:02:24 +01:00
Thaddeus Crews
a0db88335a
Implement function to throw on null pointers
• Specifically: checks if ptr == IntPtr.Zero
2023-12-17 08:52:20 -06:00
Thaddeus Crews
08e44123cb
[C#] Enable nullability for variant classes 2023-12-09 12:42:10 -06:00
Thaddeus Crews
db7a643e1c
[C#] Enable nullability for variant structs 2023-12-09 12:41:53 -06:00