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

C#: Allow use of .NET 7 #71825

Merged
merged 1 commit into from Jan 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -8,6 +8,7 @@

<!-- To generate the .runtimeconfig.json file-->
<EnableDynamicLoading>true</EnableDynamicLoading>
<RollForward>LatestMajor</RollForward>
Copy link
Member

@raulsntos raulsntos Jan 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tried using Major instead? AFAIK that should prefer the .NET 6 SDK when both are installed and may be safer than using a newer major version that may include breaking changes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but that means you can't use projects targeting .net7 in the editor if both .net6 and .net7 are installed on a machine, but after uninstalling .net6 it will then work, which is IMO really unintuitive.

Copy link
Member

@raulsntos raulsntos Jan 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 Oh yeah you are right, I agree it's unintuitive.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We talked about this the other day. The problem with Major is that (assuming both net6 and net7 are installed) if GodotPlugins targets net6, then that's what the Godot editor will load. If that happens, there will be problems if a game project targets net7, because only one runtime can be loaded.
As such, we decided LatestMajor was the way to go. The only drawback here is the risk of a future .NET version breaking backwards compatibility. I think this is a risk we will have to live with, but it would be great if we can have a workaround for users in case that ever happens. My idea was to add a project/editor setting to use Major if desired.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The question really is how long term .NET 6 support is supposed to be. If the plan is to fully switch to .NET 7 as soon as all the kinks are worked out, I would just not bother with being able to use 6 over 7, when both are installed. If on the other hand .NET 6 is going to remain supported for the full 4.0 release, I would load the framework based on the runtime config of the user project and only fall back to the runtime config of GodotPlugins, if the project was not built yet / the desired target framework is not installed.

</PropertyGroup>

<ItemGroup>
Expand Down
Expand Up @@ -104,7 +104,7 @@ public Godot.Variant.Type Expected
}
}

[StructLayout(LayoutKind.Explicit)]
[StructLayout(LayoutKind.Sequential, Pack = 8)]
// ReSharper disable once InconsistentNaming
public ref struct godot_variant
{
Expand All @@ -113,11 +113,11 @@ public Godot.Variant.Type Expected
=> (godot_variant*)Unsafe.AsPointer(ref Unsafe.AsRef(in _typeField));

// Variant.Type is generated as an enum of type long, so we can't use for the field as it must only take 32-bits.
[FieldOffset(0)] private int _typeField;
private int _typeField;

// There's padding here

[FieldOffset(8)] private godot_variant_data _data;
private godot_variant_data _data;

[StructLayout(LayoutKind.Explicit)]
// ReSharper disable once InconsistentNaming
Expand Down