Skip to content

Missing Unsafe for Functions with Fixed Size Buffers #593

@skrobchik

Description

@skrobchik

The code generator adds unsafe to functions that use pointers, but not fixed size buffers. This results in error CS0214: Pointers and fixed size buffers may only be used in an unsafe context

See microsoft/wdkmetadata#87 for an example.

Relevant code:

private bool IsUnsafe(NamedDecl namedDecl, Type type)

    private bool IsUnsafe(NamedDecl namedDecl, Type type)
    {
        var remappedName = GetRemappedTypeName(namedDecl, context: null, type, out _, skipUsing: true, ignoreTransparentStructsWhereRequired: false);
        return remappedName.Contains('*', StringComparison.Ordinal);
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions