MapsterMapper / MapsterMapper/Mapster

dotnet mapper ... -p generates code that can't be compiled.

Open
#665 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C#
Stars
5.2k
Forks
410
Avg merge
2d 12h
Merged PRs (30d)
6

Description

We have POCOs with the same type name in different namespaces.
Adding `-p` fixes the ambiguous reference, but generates enum mapping like

```
Mapster.Utils.Enum.Parse(Mapster.Utils.Enum.ToString()),
```
that fails to compile with error
```
The type or namespace name 'Utils' does not exist in the namespace 'xxxxxxx'
```
Same for `Mapster.TypeAdapter`

To fix, please render
````
using Mapster;
using Mapster.Utils;
````
and non-qualified `Enum.Parse()...` even if **-p** is requested.

Thanks

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 dotnet mapper code-generation path that renders Enum and TypeAdapter references, then reproduce the case with same-named POCOs in different namespaces and the -p option. Done means the generated C# uses Mapster and Mapster.Utils imports with non-qualified references and compiles successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.