dotnet / dotnet/macios

[Generator] Add a smarter generation when [NullAllowed] and [BindAs (..)] are combined

Open
#9,219 1 comment 0 reactions 0 assignees View on GitHub
copilot-candidate enhancement generator
Dominant language
C#
Stars
2.9k
Forks
576
Avg merge
2d 13h
Merged PRs (30d)
96

Description

We have APIs that do point to a NSNumber that can be null and we use bind as, for example, we find cases were we have to write:

```csharp
[NullAllowed]
[BindAs (typof (int?)]
NSNumber Foo { get; set; }
```

This is at least, error prone, since we can have cases in which we do by accident:

```csharp
[NullAllowed]
[BindAs (typof (int)]
NSNumber Foo { get; set; }
```

The error is hard to notice while writing the code or doing a review since it is a single character. We should:

1. Teach the generator to raise a warning with the mismatch.
2. Make BindAs smarter, do we need the ? because we already have NullAllowed, just do it.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.