Skip to content

RMG089 should not be reported when mapping from types with disabled nullability #1942

@Dreamescaper

Description

@Dreamescaper

Please do the checklist before filing an issue:

  • I have read the documentation, including the FAQ
  • I can reproduce the bug using the latest prerelease version
  • I have searched existing discussion and issue to avoid duplicates

Describe the bug

I have a project A (or nuget package) with disabled nullability. Project B with enabled nullability, which references project A.
When mapping string property from type from project A to type from project B, Mapperly reports RMG089

Mapping the nullable source property Id of NonNullableDtos.EntityDto to the target property Id of MapperlyRepro.Entity which is not nullable

However, source property is not nullable - it does not report any nullability at all.
Since C# does not report any warnings in such case, I expect Mapperly to not report any warnings as well.

Repro
MapperlyRepro.zip

Declaration code

#nullable disable
public class EntityDto
{
    public string Id { get; set; }
}

#nullable enable
public class Entity
{
    public required string Id { get; set; }
}

[Mapper]
public static partial class Mapper
{
    public static partial Entity MapFromDto(this EntityDto dto);
}

Reported relevant diagnostics

  • RMG089 - Mapping the nullable source property Id of NonNullableDtos.EntityDto to the target property Id of MapperlyRepro.Entity which is not nullable

Environment (please complete the following information):

  • Mapperly Version: 4.3.0-next.3
  • Nullable reference types: both
  • Target Framework: .net8.0
  • Compiler Version: '4.14.0-3.25412.6 (c167adef)'
  • C# Language Version: 12.0
  • IDE: Version 17.14.13 (August 2025)
  • OS: Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions