Skip to content

Update code fix for SYSLIB1054 to use a collection expression #96964

Closed
@Captain-Quack

Description

@Captain-Quack

The code fix for SYSLIB1054 generates an attribute that contains the now outdated new Type[] { ... } syntax. This should be replaced with a collection expression instead.

Proposed Change

class C 
{
    [LibraryImport(...)]
-   [UnmanagedCallConv(CallConvs = new Type[] { ... })]
+   [UnmanagedCallConv(CallConvs = [...])]
    public static partial void DoAThing(); 
}

Example

After the fix, this code:

/// <summary>
/// Returns if the application's window is currently fullscreen
/// </summary>
[DllImport("cool_name_here", CallingConvention = CallingConvention.Cdecl)]
public static extern bool IsWindowFullscreen();

Will change to the following:

/// <summary>
/// Returns if the application's window is currently fullscreen
/// </summary>
[LibraryImport("cool_name_here")]
[UnmanagedCallConv(CallConvs = [typeof(System.Runtime.CompilerServices.CallConvCdecl)])]
public static extern bool IsWindowFullscreen();

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions