-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Move DllImportGenerator to use DisableRuntimeMarshalling for its blittable classification #64279
Merged
jkoritzinsky
merged 6 commits into
dotnet:main
from
jkoritzinsky:unmanaged-blittable-gendllimport
Feb 10, 2022
Merged
Move DllImportGenerator to use DisableRuntimeMarshalling for its blittable classification #64279
jkoritzinsky
merged 6 commits into
dotnet:main
from
jkoritzinsky:unmanaged-blittable-gendllimport
Feb 10, 2022
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ghost
assigned jkoritzinsky
Jan 25, 2022
This was referenced Jan 26, 2022
Closed
jkoritzinsky
force-pushed
the
unmanaged-blittable-gendllimport
branch
2 times, most recently
from
February 8, 2022 19:51
346bbe9
to
da78717
Compare
runtime-libraries enterprise-linux failure will be fixed by #65027 |
jkoritzinsky
requested review from
imhameed,
lambdageek,
MichalStrehovsky,
SamMonoRT and
vargaz
as code owners
February 8, 2022 22:29
jkoritzinsky
force-pushed
the
unmanaged-blittable-gendllimport
branch
from
February 8, 2022 23:07
da78717
to
abd7327
Compare
...time.InteropServices/gen/DllImportGenerator/Analyzers/ConvertToGeneratedDllImportAnalyzer.cs
Outdated
Show resolved
Hide resolved
...rvices/gen/Microsoft.Interop.SourceGeneration/Marshalling/NullMarshallingGeneratorFactory.cs
Outdated
Show resolved
Hide resolved
...stem.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/Forwarder.cs
Show resolved
Hide resolved
The mono changes look ok. |
This was referenced Feb 9, 2022
jkoritzinsky
force-pushed
the
unmanaged-blittable-gendllimport
branch
2 times, most recently
from
February 9, 2022 18:16
1141b89
to
a8b0296
Compare
…table-struct designations. Require DisableRuntimeMarshalling for all uses of the new attributed marshalling model, not just blittable cases Update generator tests to apply DisableRuntimeMarshalling where requried. Allow custom type marshalling with an always-blittable primitive or pointer-sized Value property to not require disabled runtime marshalling. This allows array types to be marshalled without requiring turning off runtime marshalling. Update some of the snippets used in the DllImportGenerator unit tests.
…e for DynamicMethods in Mono.
Apply DisableRuntimeMarshalling to System.Private.CoreLib Convert over some more DllImports as we can now handle public blittable types since unmanaged == blittable Get dotnet/runtime building with the move to DisableRuntimeMarshalling-based blittability rules Use GeneratedDllImport everywhere in NativeAOT corelibs Fix Test.CoreLib build. Add CharSet Fix modifier Fix allconfigurations build Add DisableRuntimeMarshalling to more projects. Condition DisableRuntimeMarshalling inclusion on net7.0, not on current TFM. Fix test build locally Remove some cases of runtime marshalling in assemblies that have runtime marshalling disabled. Fix build failures. Add CharSet Fix a few non-blittable P/Invokes. Handle modopts/modreqs on an element in a signature Fix adding partial Add back the ErrorWriterDelegate SetLastError in all the callbacks. Handle null Use SafeHandle instead of CriticalHandle. Fix base class Add manual non-blittable marshalling support for System.Diagnostics.EventLog. Write manual marshaller for StringBuilder usage in Interop.winhttp.cs Fix buffer size (sizeof char != 1) Fix managed build Make more DllImports generated in Registry/IO Remove some dead code and make a few assemblies not disable runtime marshalling as they use a ton of it and I really don't want to rewrite all of it if I can avoid it. Fix WebSocket P/Invokes Make another WinHttp P/Invoke generated. Fix libraries test build. Fix watcher test build again Remove extraneous [Out] on a blittable array Fix various test failures due to incorrect marshalling info/manual marshalling. Signed-off-by: Jeremy Koritzinsky <jekoritz@microsoft.com>
Fix and add tests for forwarding MarshalAs for arrays.
…alizing GDI+ v2 consistently.
jkoritzinsky
force-pushed
the
unmanaged-blittable-gendllimport
branch
from
February 9, 2022 23:33
a8b0296
to
86c0f5b
Compare
AaronRobinsonMSFT
approved these changes
Feb 9, 2022
The runtime-libraries enterprise-linux failure is an unrelated networking issue. |
This was referenced Mar 2, 2022
ghost
locked as resolved and limited conversation to collaborators
Mar 13, 2022
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Instead of using
[BlittableType]
attributes to track the runtime's blittable concept through the type system, use the newDisableRuntimeMarshalling
attribute and use "non-auto-layout unmanaged" as our definition for "requires no marshalling".This PR updates Microsoft.Interop.SourceGeneration to require
[assembly:DisableRuntimeMarshalling]
to be applied whenever a user defines a source-generated P/Invoke with a native parameter or return type that isn't a primitive, pointer, or function pointer. Additionally, since the current default marshalling forbool
in the generator is as a WindowsBOOL
, allowbool
to be specified for easy back-compatibility for now.Because the runtime repo is an early adopter of the generator, this PR also updates the runtime to build with marshalling disabled where required. Some libraries (System.Drawing.Common, OleDb) use a lot of non-blittable marshalling in delegate-based interop scenarios or COM-focused marshalling and don't have any source-generated P/Invokes that require the
DisableRuntimeMarshalling
attribute, so those assemblies don't have the attribute applied to try to keep this PR a little smaller.This PR also includes a few fixes that were required to get all tests passing:
[In, Out, MarshalAs]
forwarding support for partially supported P/Invokes on downlevel platforms[DisableRuntimeMarshalling]
-compliant.