Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions AutoInterfaceSample/AutoInterfaceSample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,11 @@
</ItemGroup>

<ItemGroup>
<Analyzer Include="..\BeaKona.AutoInterfaceGenerator\bin\Debug\netstandard2.0\BeaKona.AutoInterfaceGenerator.dll" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
<PackageReference Include="NLog" Version="5.2.8" />
<PackageReference Include="Serilog" Version="3.1.1" />
<ProjectReference Include="..\BeaKona.AutoInterfaceAttributes\BeaKona.AutoInterfaceAttributes.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="true" />
<ProjectReference Include="..\TestInterfacesNetStandard\TestInterfacesNetStandard.csproj" />
</ItemGroup>
<!--<Analyzer Include="..\BeaKona.AutoInterfaceGenerator\bin\Debug\netstandard2.0\BeaKona.AutoInterfaceGenerator.dll" />-->
<ProjectReference Include="..\BeaKona.AutoInterfaceAttributes\BeaKona.AutoInterfaceAttributes.csproj" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\TestInterfaces\TestInterfaces.csproj">
<Aliases></Aliases>
</ProjectReference>
<ProjectReference Include="..\BeaKona.AutoInterfaceGenerator\BeaKona.AutoInterfaceGenerator.csproj" OutputItemType="Analyzer" />
</ItemGroup>

</Project>
78 changes: 15 additions & 63 deletions AutoInterfaceSample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}*/

}

Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down