Skip to content

Commit

Permalink
GenerateAutoAs preview
Browse files Browse the repository at this point in the history
  • Loading branch information
beakona committed Dec 1, 2023
1 parent dc35de0 commit 34a1788
Show file tree
Hide file tree
Showing 6 changed files with 401 additions and 6 deletions.
53 changes: 49 additions & 4 deletions AutoInterfaceSample/Program.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
using System;
using BeaKona;
using System;
using System.Collections;
using System.Collections.Generic;

namespace AutoInterfaceSample
namespace AutoInterfaceSample.Test
{
public class Program
{
public static void Main()
{
//System.Diagnostics.Debug.WriteLine(BeaKona.Output.Debug_Person.Info);
//System.Diagnostics.Debug.WriteLine(BeaKona.Output.Debug_TestClass_1.Info);
//IArbitrary<int> p = new Person();
//int f;
//int g = 1;
//p.Method(1, out f, ref g, "t", 1, 2, 3);

TestClass<int> t = new TestClass<int>();
var x = t.AsMy1();

IPrintableComplex p = new Person2();
p.Print();
p.PrintComplex();
Expand All @@ -24,13 +30,52 @@ interface IPrintableComplex
void PrintComplex();
}

public interface IMy1Base
{
}

public interface IMy1<H> : IMy1Base
{
}

internal interface IMy2<T>
{
}

internal interface IMy2<T1, T2>
{
}

internal interface IMy3
{
}

internal interface @internal
{
}

public abstract class TestClassBase : IMy3
{
}

[GenerateAutoAs(EntireInterfaceHierarchy = true, SkipSystemInterfaces = false)]
public partial class TestClass<T> : TestClassBase, IMy1<T>, IMy2<int>, IMy2<string>, IMy2<string, string>, IEnumerable<int>, @internal
{
IEnumerator IEnumerable.GetEnumerator() => this.GetEnumerator();

public IEnumerator<int> GetEnumerator()
{
throw new NotImplementedException();
}
}

public class SimplePrinter //: IPrintableComplex
{
public void Print() { Console.WriteLine("OK"); }
public void PrintComplex() { Console.WriteLine("OKC"); }
}

public partial class Person2 //: IPrintableComplex
public partial class Person2 /*: IPrintableComplex*/
{
//[BeaKona.AutoInterface(typeof(IPrintableComplex), AllowMissingMembers = true, MemberMatch = BeaKona.MemberMatchTypes.Public)]
//private readonly SimplePrinter aspect1 = new SimplePrinter();
Expand Down
12 changes: 12 additions & 0 deletions BeaKona.AutoInterfaceAttributes/GenerateAutoAsAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;
using System.Diagnostics;

namespace BeaKona;

[Conditional("CodeGeneration")]
[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
public sealed class GenerateAutoAsAttribute : Attribute
{
public bool EntireInterfaceHierarchy { get; set; } = false;
public bool SkipSystemInterfaces { get; set; } = true;
}
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,6 @@ EventModel CreateEvent(IEventSymbol @event)
return error == false && anyReasonToEmitSourceFile ? builder.ToString() : null;
}


/// <summary>
/// Created on demand before each generation pass
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<RepositoryUrl>https://github.com/beakona/AutoInterface</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);_AddAnalyzersToOutput</TargetsForTfmSpecificContentInPackage>
<Version>1.0.31</Version>
<Version>1.0.32</Version>
<IsRoslynComponent>true</IsRoslynComponent>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
</PropertyGroup>
Expand Down
Loading

0 comments on commit 34a1788

Please sign in to comment.