microsoft / microsoft/win32metadata

NullReferenceException when ClangSharpSourceToWinmd attempts to translate a function pointer

Open
#1,742 3 comments 1 reaction 0 assignees View on GitHub
Dominant language
C++
Stars
1.5k
Forks
149
Avg merge
5d 16h
Merged PRs (30d)
4

Description

Given a function pointer (added in [C# 9](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-9.0/function-pointers)):

```csharp
namespace Test
{
public unsafe partial struct MyStruct
{
public delegate* unmanaged[Stdcall] Handler;
}
}
```

ClangSharpSourceToWinmd will raise a `NullReferenceException` in `ClangSharpSourceWimmdGenerator.GetTypeRefOrDef` as function pointer types have a `null` `ContainingNamespace`.

Contributor guide

Open the contributing guide

Research direction

Start with ClangSharpSourceToWinmd and the ClangSharpSourceWimmdGenerator.GetTypeRefOrDef method named in the report. Reproduce the failure using the provided C# function-pointer example, then trace how its null ContainingNamespace is handled. Done means the example translates without a NullReferenceException.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, csharp
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.