diff --git a/AutoInterfaceSample/AutoInterfaceSample.csproj b/AutoInterfaceSample/AutoInterfaceSample.csproj index ff29ac1..87c6a68 100644 --- a/AutoInterfaceSample/AutoInterfaceSample.csproj +++ b/AutoInterfaceSample/AutoInterfaceSample.csproj @@ -15,18 +15,11 @@ - - - - - - - + + + - - - + - diff --git a/AutoInterfaceSample/Program.cs b/AutoInterfaceSample/Program.cs index 6b52140..222c6f5 100644 --- a/AutoInterfaceSample/Program.cs +++ b/AutoInterfaceSample/Program.cs @@ -13,80 +13,32 @@ public static void Main() } } - public interface IB + interface IA { - protected Point Point { get; } - int X() => Point.X; - int Y => Point.Y; - static int Count => 1; - int Count2 => 2; + int X(); + int Y { get; } } - partial class C1 : IB + interface IB : IA { - [AutoInterface(typeof(IB), AllowMissingMembers = true)] private IB _inner = default!; - - System.Drawing.Point IB.Point => Point.Empty; + Point Point { get; } + int IA.X() => Point.X; + int IA.Y => Point.Y; } - public class MyDb : IDb - { - [AllowNull] - public string ConnectionString { get; [param: AllowNull] set; } = default!; - [AllowNull] - public string this[int a, [AllowNull] string b] - { - get => b ?? ""; - [param: AllowNull] - set - { - } - } - } - - partial record TestDb([property: BeaKona.AutoInterface(typeof(IDb), IncludeBaseInterfaces = true)] IDb Inner) //: IDb + partial class C1 : IB { - } - //partial record TecProgDbConnection - //{ - //[AllowNull] - //[DisallowNull] - //string IDb.ConnectionString - //{ - // get => (this.Inner as System.Data.IDbConnection)!.ConnectionString; - // //[param:MaybeNull] - // set => (this.Inner as System.Data.IDbConnection)!.ConnectionString = value; - //} - //} + [AutoInterface(typeof(IB))] private IB _inner = default!; - public interface IDb - { - [AllowNull] - string ConnectionString - { - get; - [param: AllowNull] - set; - } - - [AllowNull] - string this[int a, [AllowNull] string b] - { - get; - [param: AllowNull] - set; - } } -} + partial class D1 : IB + { -/*namespace System.Diagnostics.CodeAnalysis -{ + [AutoInterface(typeof(IB), IncludeBaseInterfaces = true)] private IB _inner = default!; - [AttributeUsage(AttributeTargets.Parameter, Inherited = false)] - internal sealed class NotNullWhenAttribute(bool returnValue) : Attribute - { - public bool ReturnValue { get; } = returnValue; } -}*/ + +} + \ No newline at end of file diff --git a/BeaKona.AutoInterfaceGenerator/AutoInterfaceSourceGenerator.cs b/BeaKona.AutoInterfaceGenerator/AutoInterfaceSourceGenerator.cs index bbbb0f8..5f383cb 100644 --- a/BeaKona.AutoInterfaceGenerator/AutoInterfaceSourceGenerator.cs +++ b/BeaKona.AutoInterfaceGenerator/AutoInterfaceSourceGenerator.cs @@ -798,7 +798,9 @@ EventModel CreateEvent(IEventSymbol @event) separatorRequired = true; } - foreach (IPropertySymbol property in @interface.GetProperties().Where(ShouldGenerate)) + foreach (IPropertySymbol property in @interface.GetProperties() + .Where(p => p.ExplicitInterfaceImplementations.Length == 0) //Only declared in current interface + .Where(ShouldGenerate)) { anyReasonToEmitSourceFile = true;