Create a .NET 6 code path for GlobalMemory #609
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary of the PR
Silk.NET.Core.csproj
NativeMemoryPointer
inside a preprocessorNET6_0_OR_GREATER
GlobalMemory.Free
andGlobalMemory.Allocate
to use the new struct.Related issues, Discord discussions, or proposals
#597
Further Comments
I don't know if this PR require testing or contain breaking changes as I am not aware of any possible problems.
I had to add
unsafe
toGlobalMemory.Free
to useNativeMemory
because that is required. And this change will affect .NET 5 and .NET Standart versions even if this change is only for .NET 6.Also: maybe it is better to use
NET6_0_OR_GREATER
directive inGlobalMemory.Free
? BecauseNET6_0
targets only one version, and I think next year someone will have to do this change anyway.NativeMemoryPtr
requires minimum .NET 6 too. Also I had to make some convertions line(nint)
and(nuint)
to be able to useNativeMemory
.I think that
GlobalMemory.Allocate
requires a little work, because the preprocesor directives now are.. Confusing.Now it is:
#if NET6_0
#elif !NET5_0
#else
I think it is better to make
#if NET6_0
#elif NET5_0
#else
and make according changes to the code. Only to make the code more readable.