roslyn-analyzers icon indicating copy to clipboard operation
roslyn-analyzers copied to clipboard

Analyzer ignores Inheritance

Open p3t3rix opened this issue 5 years ago • 2 comments

I tested the analyzer and realized that it does ignore inheritance. Given the following Code

     public class Base
    {
        public int A { get; set; }
    }


    public class Child : Base
    {
        public int B { get; set; }
    }

    public class Programm {
        public static void Main()
        {
            //AssignAll enable
            var x = new Child
            {

            };
            var y = new Child
            {
                B = 2
            };
        }
    }

I would have expected that y also throws an error. But at the moment only x will complain about missing members.

p3t3rix avatar Jul 02 '19 12:07 p3t3rix

Ah, yep, I didn't test that. My usecase was simple mappings between entity types and DTO types. I'm sure it's solvable though, but as I've mentioned before I'm not actively maintaining this project and won't pursue this myself. I'd be happy to assist and merging pull requests though!

angularsen avatar Jul 02 '19 12:07 angularsen

Stumbled on this myself today, might just have the incentive to implement a fix.

angularsen avatar Sep 25 '20 19:09 angularsen

Should be fixed in 1.6.0, please give it a try.

angularsen avatar Oct 02 '22 11:10 angularsen