Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,12 @@ private void AddUsedType(ITypeSymbol typeSymbol)
AddUsedType(arrayTypeSymbol.ElementType);
}

// Handle pointer types
if (typeSymbol is IPointerTypeSymbol pointerTypeSymbol)
{
AddUsedType(pointerTypeSymbol.PointedAtType);
}

// Handle generic type arguments
if (typeSymbol is INamedTypeSymbol namedTypeSymbol)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1370,4 +1370,33 @@ await CreateProjectBuilder()
.WithSourceCode(SourceCode)
.ValidateAsync();
}

[Fact]
public async Task InternalStructUsedAsPointerInMethodParameter_NoDiagnostic()
{
const string SourceCode = """
using System;

internal struct SECURITY_ATTRIBUTES
{
internal uint nLength;
internal IntPtr lpSecurityDescriptor;
internal bool bInheritHandle;
}

public class FileOperations
{
private static unsafe void CreateFilePrivate(
string lpFileName,
int dwDesiredAccess,
int dwShareMode,
SECURITY_ATTRIBUTES* lpSecurityAttributes)
{
}
}
""";
await CreateProjectBuilder()
.WithSourceCode(SourceCode)
.ValidateAsync();
}
}