{"record":{"id":"95017218c630b7a0","repo":"LuckyPennySoftware/AutoMapper","slug":"the-interface-has-a-conflicting-property-property","errorCode":null,"errorMessage":"The interface has a conflicting property {property.Name}","messagePattern":"The interface has a conflicting property (.+?)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/AutoMapper/Execution/ProxyGenerator.cs","lineNumber":75,"sourceCode":"            addIl.Emit(OpCodes.Dup);\n            addIl.Emit(OpCodes.Ldfld, propertyChangedField);\n            addIl.Emit(OpCodes.Ldarg_1);\n            addIl.Emit(OpCodes.Call, delegateMethod);\n            addIl.Emit(OpCodes.Castclass, typeof(PropertyChangedEventHandler));\n            addIl.Emit(OpCodes.Stfld, propertyChangedField);\n            addIl.Emit(OpCodes.Ret);\n            typeBuilder.DefineMethodOverride(eventAccessor, method);\n        }\n        void GenerateFields()\n        {\n            Dictionary<string, PropertyEmitter> fieldBuilders = [];\n            foreach (var property in PropertiesToImplement())\n            {\n                if (fieldBuilders.TryGetValue(property.Name, out var propertyEmitter))\n                {\n                    if (propertyEmitter.PropertyType != property.Type && (property.CanWrite || !property.Type.IsAssignableFrom(propertyEmitter.PropertyType)))\n                    {\n                        throw new ArgumentException($\"The interface has a conflicting property {property.Name}\", nameof(interfaceType));\n                    }\n                }\n                else\n                {\n                    fieldBuilders.Add(property.Name, new PropertyEmitter(typeBuilder, property, propertyChangedField));\n                }\n            }\n        }\n        List<PropertyDescription> PropertiesToImplement()\n        {\n            List<PropertyDescription> propertiesToImplement = [];\n            List<Type> allInterfaces = [.. interfaceType.GetInterfaces(), interfaceType];\n            // first we collect all properties, those with setters before getters in order to enable less specific redundant getters\n            foreach (var property in\n                allInterfaces.Where(intf => intf != typeof(INotifyPropertyChanged))\n                    .SelectMany(intf => intf.GetProperties())\n                    .Select(p => new PropertyDescription(p))\n                    .Concat(typeDescription.AdditionalProperties))","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/LuckyPennySoftware/AutoMapper/blob/dfa6dd587c5854b4beee5934beb39ba6e9569b84/src/AutoMapper/Execution/ProxyGenerator.cs#L57-L93","documentation":"Thrown during proxy generation when an interface (or an interface and its inherited interfaces) declares two properties with the same name but incompatible types. The GenerateFields method tracks properties by name in a dictionary; when a name collision occurs and the types are incompatible (the existing property type is not assignable from the new type, or they differ and the new property is writable), it throws ArgumentException.","triggerScenarios":"Mapping to an interface that inherits from two other interfaces, each declaring a property with the same name but different types (diamond inheritance conflict). Also triggered when using AsProxy or GetSimilarType on such a conflicting interface.","commonSituations":"An interface inherits IFoo { string Name } and IBar { int Name }; combining DTO interfaces that accidentally reuse a property name with different types.","solutions":["Redesign the interface hierarchy so no two inherited interfaces declare a property with the same name and incompatible types.","Map to a concrete class that disambiguates the conflicting properties instead of using a proxy.","Split the mapping so each conflicting interface is mapped separately."],"exampleFix":"// before — conflicting property names across interfaces\npublic interface IFoo { string Id { get; set; } }\npublic interface IBar { int Id { get; set; } }\npublic interface ICombined : IFoo, IBar { }\nCreateMap<Source, ICombined>().AsProxy();\n\n// after — rename one property to avoid conflict\npublic interface IBar { int Number { get; set; } }\npublic interface ICombined : IFoo, IBar { }\nCreateMap<Source, ICombined>().AsProxy();","handlingStrategy":"validation","validationCode":"// Check for conflicting property names across an interface hierarchy before proxying\nstatic bool HasConflictingProperties(Type interfaceType)\n{\n    var allProps = interfaceType.GetInterfaces().Append(interfaceType)\n        .SelectMany(i => i.GetProperties())\n        .GroupBy(p => p.Name);\n    foreach (var g in allProps)\n    {\n        var types = g.Select(p => p.PropertyType).Distinct().ToArray();\n        if (types.Length > 1 && !types.All(t => types.All(o => t.IsAssignableFrom(o) || o.IsAssignableFrom(t))))\n            return true;\n    }\n    return false;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Avoid diamond interface inheritance where two parent interfaces declare same-named properties with different types.","Audit interface hierarchies for property name conflicts before using AsProxy.","Map to a concrete class as an alternative when interface conflicts cannot be resolved."],"tags":["proxy","interface","reflection-emit","type-conflict"],"backgroundTag":null,"analyzedSha":"dfa6dd587c5854b4beee5934beb39ba6e9569b84","analyzedAt":"2026-08-13T19:56:33.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}