Skip to content

CA5392/CA5393 on cross-platform code #2855

@Zenexer

Description

@Zenexer

Analyzer package

Microsoft.CodeAnalysis.FxCopAnalyzers

Package Version

v2.9.5-beta1.final (Latest)

Diagnostic ID

  • CA5392
  • CA5393

Repro steps

CA5392:

[DllImport("System.Security.Cryptography.Native.OpenSsl")]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern unsafe bool CryptoNative_GetRandomBytes(byte* buffer, int length);

CA5393:

[DllImport("System.Security.Cryptography.Native.OpenSsl")]
[DefaultDllImportSearchPaths(DllImportSearchPath.LegacyBehavior)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern unsafe bool CryptoNative_GetRandomBytes(byte* buffer, int length);

Expected behavior

DefaultDllImportSearchPathsAttribute appears to be ignored on platforms other than Windows, and LegacyBehavior is the only available option. Warnings that are unavoidable on platforms other than Windows should be disabled by default.

Actual behavior

CA5392 and CA5393 are enabled by default.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions