Interface inheritance and duplicate fields

Open
#58 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

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

Research direction

No files, tests, or entry points are named. Start by tracing how C# interface inheritance is flattened during DTO generation, then determine where duplicate properties can be detected. Done means DTOs with duplicate flattened properties are rejected, including duplicates with different types or explicit interface implementations.

Written by the indexing model from the issue text.

Description

Since we support inheritance on the C# side, but want to convert it to "extension", we need to prevent the following case:

interface A { int PropA { get; set; } }
interface B { int PropA { get; set; } }
class C : A, B { public int PropA { get; set; } }

Currently, both A and B will have PropA. C won't, but it will extend both A and B and the resulting type will need to support both. That is wrong as we don't really know which PropA we are talking about. And if these two differ in type, e.g. when they are done like this:

interface A { int PropA { get; set; } }
interface B { string PropA { get; set; } }
class C : A, B { int A.PropA { get; set; } string B.PropA { get; set; } }

or like that

interface A { int PropA { get; set; } }
interface B { string PropA { get; set; } }
class M : A { public int PropA { get; set; } }
class C : M, B { new public string PropA { get; set; } }

we have totally undecidable case.

I suggest blocking this - i.e. when any DTO has a duplicate property when "flattened", reject it. What are your thoughts?

Dominant language
C#
Stars
9
Forks
2
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

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.

More from leancodepl/contractsgenerator

All issues in leancodepl/contractsgenerator

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.