microsoft / microsoft/CsWin32

Emit nullable ref annotated code

Open
#130 6 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
C#
Stars
2.5k
Forks
124
Avg merge
1d 3h
Merged PRs (30d)
9

Description

When the project langversion is >= 8, could you also put #nullable enable or at least #nullable annotations in the file or around the parameter declaration and use SafeHandle? as the parameter type so that IntelliSense shows me that nulls are anticipated?

Originally posted by @jnm2 in https://github.com/microsoft/CsWin32/issues/129#issuecomment-781466704

If we annotate at all, we need to be consistent so users can trust that a parameter is required when we don't annotate it. The metadata has many [Optional] annotations on its inputs to help with this, but I don't know how consistently it is applied.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review issue #129 and the generator logic that consumes Win32 metadata, especially its [Optional] inputs, to determine the nullable-annotation policy for langversion >= 8. Done means generated signatures consistently communicate anticipated nulls, including SafeHandle? where the metadata supports it, without making required parameters appear optional.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.