MapsterMapper / MapsterMapper/Mapster

Ignore nullable property does warning CS8603

Open
#520 8 comments 2 reactions 0 assignees View on GitHub

A pull request for this has already been merged.

  • #991 by @DocSvartz — merged
improvement waiting for info
Dominant language
C#
Stars
5.2k
Forks
410
Avg merge
2d 12h
Merged PRs (30d)
6

Description

.Net 7.0 with nullable enabled

public struct Dest
{
    public string Name { get; set; }
    public string? NullableString { get; set; }
}

public struct Source
{
    public string Name { get; set; }
}

public class Mapping : IRegister
{
    public void Register(TypeAdapterConfig config)
    {
        config.NewConfig<Source, Dest>()
            .Ignore(d => d.NullableString); // this string a got a warning message CS8603: Possible null reference return
    }
}

image

I think that signature of Ignore method need to be
public TypeAdapterSetter<TSource, TDestination> Ignore(params Expression<Func<TDestination, object?>>[] members);

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

Start by locating the Ignore method signature and reproduce the nullable-enabled C# example from the issue. Review linked pull request #991 for the existing resolution; done means the Ignore call no longer produces warning CS8603.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend-api-design
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.