Skip to content

Commit

Permalink
forward nonpublic attributes [method parameter, class members]
Browse files Browse the repository at this point in the history
  • Loading branch information
beakona committed Mar 14, 2024
1 parent 9901aa5 commit 0543ef8
Show file tree
Hide file tree
Showing 5 changed files with 1,427 additions and 85 deletions.
1 change: 1 addition & 0 deletions AutoInterfaceSample/AutoInterfaceSample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

<ItemGroup>
<Analyzer Include="..\BeaKona.AutoInterfaceGenerator\bin\Debug\netstandard2.0\BeaKona.AutoInterfaceGenerator.dll" />
<PackageReference Include="NLog" Version="5.2.8" />
<ProjectReference Include="..\BeaKona.AutoInterfaceAttributes\BeaKona.AutoInterfaceAttributes.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="true" />
</ItemGroup>

Expand Down
79 changes: 6 additions & 73 deletions AutoInterfaceSample/Program.cs
Original file line number Diff line number Diff line change
@@ -1,88 +1,21 @@
using System;
using System.Diagnostics.CodeAnalysis;
using NLog;

namespace AutoInterfaceSample.Test
{
public partial record TestRecord([property: BeaKona.AutoInterface] ILogger Logger)
public partial record TestRecord([property: BeaKona.AutoInterface(IncludeBaseInterfaces = true)] ILogger Logger)
{
//[field: BeaKona.AutoInterface]
//public ILogger Logger { get; }

//[BeaKona.AutoInterface]
//private readonly ILogger logger2 = new SimpleLogger();
}

public sealed class LogEventProperty<T>
{
}

[AttributeUsage(AttributeTargets.ReturnValue | AttributeTargets.Parameter | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.GenericParameter, AllowMultiple = true)]
public class TestAttribute : Attribute
{
}

public sealed class SimpleLogger : ILogger
{
public bool BindProperty<[Test] T>(string? propertyName, object? value, bool destructureObjects, [NotNullWhen(true)] out LogEventProperty<T>? property, [Test] params int[] values)
{
property = default;
return false;
}

[Test]
public int Count
{
[return: Test]
[Test]
get => 1;
[return: Test]
[Test]
set
{
}
}
public int Length
{
get => 1;
set { }
}
}

public class Program
{
public static void Main()
{
//System.Diagnostics.Debug.WriteLine(BeaKona.Output.Debug_TestClass_1.Info);
//System.Diagnostics.Debug.WriteLine(BeaKona.Output.Debug_TestRecord.Info);

ILogger p = new TestRecord(new SimpleLogger());
var result = p.BindProperty<int>("test", 1, false, out var property, 1, 2, 3);
}
}

public interface ILogger
{
[Test]
[return: Test]
[return: Test]
bool BindProperty<[Test] T>(string? propertyName, object? value, bool destructureObjects, [NotNullWhen(true)] out LogEventProperty<T>? property, [Test] params int[] values);

[Test]
int Count
{
[return: Test]
[Test]
get;
[return: Test]
[Test]
set;
}

int Length
{
[return: Test]
get;
[return: Test]
set;
p.IsEnabled(LogLevel.Info);
//p.Log<int?>(LogLevel.Debug, default, 1, null, null);
//var result = p.BindProperty<int>("test", 1, false, out var property, 1, 2, 3);
}
}
}
Loading

0 comments on commit 0543ef8

Please sign in to comment.