Open jtschuster opened 1 year ago
Tagging subscribers to this area: @dotnet/interop-contrib See info in area-owners.md if you want to be subscribed.
Author: | jtschuster |
---|---|
Assignees: | - |
Labels: | `area-System.Runtime.InteropServices` |
Milestone: | 9.0.0 |
Looks like this is another case in the analyzer that got lost in the refactor. We used to warn for this case. I think it's too late in .NET 8 to add the warning given that the snap is tomorrow and I probably won't get to it today, but we can add a notice in 8 and make it a warning in 9.
Actually, it looks like the stateless and stateful code should handle this case as long as the marshaller isn't MarshalMode.Default
, at least at usage time. We should probably add a check in the analyzer as well.
Actually, it looks like the stateless and stateful code should handle this case as long as the marshaller isn't
MarshalMode.Default
, at least at usage time. We should probably add a check in the analyzer as well.
Yes, sorry, I forgot to clarify, it will warn when someone tries to use a ref parameter, but everything else indicates that the marshaller should be okay. There's still a [CustomMarshaller(typeof(Managed), MarshalMode.XRef, typeof(Bidirectional))]
with no warnings, but when used in a method the analyzer says there isn't a marshaller for MarshalMode.XRef
.
These lines make it seem like there should be some kind of warning.
https://github.com/dotnet/runtime/blob/dd43febd533ff740a5941701239bac904279d9f8/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/ManualTypeMarshallingHelper.cs#L216-L225
These lines require that the non-caller-allocated-buffer method is present for bidirectional.
https://github.com/dotnet/runtime/blob/dd43febd533ff740a5941701239bac904279d9f8/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/ManualTypeMarshallingHelper.cs#L549-L551