Skip to content

[Mono] Add support for DisableRuntimeMarshallingAttribute #61685

Open
@lambdageek

Description

@lambdageek

The DisableRuntimeMarshallingAttribute is added to a module to indicate that it should:

  • Consider all unmanaged types as blittable
  • Promise that the current assembly does not need the default runtime marshaling behavior (that is responsible for converting strings between encodings, supporting SafeHandle, etc, etc). The idea is that a DllImportGenerator is used to generate those kinds of wrappers, and the runtime is only responsible for dealing with primitive types.

For mono that means:

We can drop the component if every single assembly meets one of these criteria:
* Is also tagged with the DisableRuntimeMarshalingAttribute.
* Uses only PInvokes with blitable types

Tooling consists of the RuntimeMarhsalingScannner which scans assemblies for these criteria.

The user sets RuntimeMarshaling to one of three values: Auto, Disable, and Enable. Auto uses the RuntimeMarshalingScanner to scan all assemblies, and drops the component if all assemblies meet the criteria. Disable forces disabling of runtime marshaling, and the SDK will emit warnings for incompatible assemblies. Enable preserves runtime marshaling, regardless of the results of the RuntimeMarshalingScanner.

Implementation plan:

  • First pass implements the scanner, but this can only implement warnings on an assembly eevel
  • Platform order: wasm, iOS, android
  • Second version uses source analyzer for better errors.

Metadata

Metadata

Assignees

Labels

area-Interop-monotrackingThis issue is tracking the completion of other related issues.

Type

No type

Projects

Status

No status

Relationships

None yet

Development

No branches or pull requests

Issue actions