Skip to content
Open
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>
66 changes: 18 additions & 48 deletions AutoInterfaceSample/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#nullable enable
using BeaKona;
using System.Diagnostics.CodeAnalysis;
using System.Drawing;

namespace AutoInterfaceSample.Test
{
Expand All @@ -11,64 +13,32 @@ public static void Main()
}
}

public class MyDb : IDb
interface IA
{
[AllowNull]
public string ConnectionString { get; [param: AllowNull] set; } = default!;

[AllowNull]
public string this[int a, [AllowNull] string b]
{
get => b ?? "";
[param: AllowNull]
set
{
}
}
int X();
int Y { get; }
}

partial record TestDb([property: BeaKona.AutoInterface(typeof(IDb), IncludeBaseInterfaces = true)] IDb Inner) //: IDb
interface IB : IA
{
Point Point { get; }
int IA.X() => Point.X;
int IA.Y => Point.Y;
}

//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;
//}
//}

public interface IDb
partial class C1 : IB
{
[AllowNull]
string ConnectionString
{
get;
[param: AllowNull]
set;
}

[AllowNull]
string this[int a, [AllowNull] string b]
{
get;
[param: AllowNull]
set;
}
[AutoInterface(typeof(IB))] private IB _inner = default!;

}
}
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 @@ -787,7 +787,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