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>
63 changes: 11 additions & 52 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,21 @@ public static void Main()
}
}

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
interface IB
{
protected Point Point { get; }
int X() => Point.X;
int 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), AllowMissingMembers = true)] private IB _inner = default!;

}
}

/*namespace System.Diagnostics.CodeAnalysis
{

[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 @@ -675,6 +675,12 @@ private static bool IsDuckImplementation(ITypeSymbol receiverType, ITypeSymbol i

bool ShouldGenerate(ISymbol member)
{

if (member.DeclaredAccessibility is not Accessibility.Public)
{
//ignore members with "protected" modifier
return false;
}
foreach (var reference in references)
{
if (reference.AllowMissingMembers)
Expand Down