From 6391515c192b2923060012d44d862b54c0eb21c4 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Fri, 24 May 2024 13:16:14 +0100 Subject: [PATCH] More options (#5) * update generator and tests * Add ImplementationOptions * option tests * fix some tests * UseExtendedInterfaces with flag enum parsing * add test for using base interfaces instead of interface * add ProxyForBaseInterface * add extra overload * don't put new if we're replacing interfaces * really remove AutoMapper * remove akka and fix up interface * Bigger bump for version * adjust readme --- README.md | 36 ++- Speckle.ProxyGenerator.sln | 9 - .../Http/IHttpClient.cs | 3 +- .../ProxyInterfaceConsumer/IAddress.cs | 2 +- .../ProxyInterfaceConsumer.csproj | 2 +- .../Interfaces/IAddressUid.cs | 7 - .../Interfaces/ILocalActorRefProvider.cs | 7 - .../ProxyInterfaceConsumerForAkka/Program.cs | 18 -- .../ProxyInterfaceConsumerForAkka.csproj | 30 --- .../ProxyInterfaceConsumerForPnP.csproj | 1 - .../ProxyInterfaceConsumerViaNuGet.csproj | 1 - .../Extensions/NamedTypeSymbolExtensions.cs | 23 +- .../FileGenerators/BaseGenerator.cs | 28 ++- .../FileGenerators/ExtraFilesGenerator.cs | 33 ++- .../PartialInterfacesGenerator.cs | 38 +++- .../ProxyClassesGenerator.AutoMapper.cs | 42 ---- .../FileGenerators/ProxyClassesGenerator.cs | 4 +- .../Models/ProxyData.cs | 14 +- .../Speckle.ProxyGenerator.csproj | 2 +- .../AttributeArgumentListParser.cs | 55 ++--- .../SyntaxReceiver/ProxySyntaxReceiver.cs | 2 +- .../Types/FluentBuilderAttributeArguments.cs | 2 +- .../ProxyInterfaceGeneratorAccessibility.cs | 14 ++ .../Utils/MemberHelper.cs | 3 +- .../AkkaTests.cs | 2 +- ...Akka.Actor.LocalActorRefProviderProxy.g.cs | 2 +- ...urce.AkkaActor.ILocalActorRefProvider.g.cs | 2 +- .../Destination/INoNamespace.g.cs | 2 +- ....SharePoint.Client.ClientContextProxy.g.cs | 2 +- ...t.SharePoint.Client.ClientObjectProxy.g.cs | 2 +- ...oint.Client.ClientRuntimeContextProxy.g.cs | 2 +- ...harePoint.Client.SecurableObjectProxy.g.cs | 2 +- .../Microsoft.SharePoint.Client.WebProxy.g.cs | 2 +- .../Destination/NoNamespaceProxy.g.cs | 2 +- ...ests.Namespace1.ClassInNamespaceProxy.g.cs | 2 +- ...torTests.Namespace1.IClassInNamespace.g.cs | 2 +- ...ests.Namespace2.ClassInNamespaceProxy.g.cs | 2 +- ...torTests.Namespace2.IClassInNamespace.g.cs | 2 +- ...eGeneratorTests.Source.Generic`1Proxy.g.cs | 2 +- ...ourceGeneratorTests.Source.HumanProxy.g.cs | 2 +- ...eSourceGeneratorTests.Source.IGeneric.g.cs | 2 +- ...urceGeneratorTests.Source.IHttpClient.g.cs | 2 +- ...ratorTests.Source.IHttpMessageInvoker.g.cs | 6 +- ...aceSourceGeneratorTests.Source.IHuman.g.cs | 2 +- ...eneratorTests.Source.IMixedVisibility.g.cs | 2 +- ...ceGeneratorTests.Source.IOperatorTest.g.cs | 2 +- ...ceSourceGeneratorTests.Source.IPerson.g.cs | 2 +- ...eGeneratorTests.Source.IPersonExtends.g.cs | 2 +- ...eratorTests.Source.ITestClassInternal.g.cs | 2 +- ...rceGeneratorTests.Source.IÜberGeneric.g.cs | 2 +- ...atorTests.Source.MixedVisibilityProxy.g.cs | 2 +- ...neratorTests.Source.OperatorTestProxy.g.cs | 2 +- ...eratorTests.Source.PersonExtendsProxy.g.cs | 2 +- ...urceGeneratorTests.Source.PersonProxy.g.cs | 2 +- ...eratorTests.Source.PnP.IClientContext.g.cs | 2 +- ...neratorTests.Source.PnP.IClientObject.g.cs | 10 +- ...ests.Source.PnP.IClientRuntimeContext.g.cs | 6 +- ...atorTests.Source.PnP.ISecurableObject.g.cs | 4 +- ...eSourceGeneratorTests.Source.PnP.IWeb.g.cs | 4 +- ...orTests.Source.TestClassInternalProxy.g.cs | 2 +- ...eratorTests.Source.ÜberGeneric`3Proxy.g.cs | 2 +- .../System.Net.Http.HttpClientProxy.g.cs | 2 +- ...stem.Net.Http.HttpMessageInvokerProxy.g.cs | 2 +- .../InheritedInterfaceTests.cs | 55 +++-- .../PnPTests.cs | 10 +- ...y_Should_GenerateCorrectFiles.verified.txt | 39 +++- ...rateFiles_ForClassWithIgnores.verified.txt | 39 +++- ...es_ForClassWith_BaseInterface.verified.txt | 165 ++++++++++++++ ...teFiles_ForClassWith_Extended.verified.txt | 213 ++++++++++++++++++ .../ProxyInterfaceSourceGeneratorTest.cs | 100 +++++++- .../ProxyInterfaceSourceGeneratorTests.csproj | 7 +- .../Source/Foo3.cs | 15 ++ .../Source/IBar3.cs | 5 + .../Source/IBar3Proxy.cs | 7 + .../Source/IFoo2.cs | 6 +- .../Source/IFoo3.cs | 8 + .../Source/IFoo3Proxy.cs | 3 + 77 files changed, 868 insertions(+), 278 deletions(-) delete mode 100644 src-examples/ProxyInterfaceConsumerForAkka/Interfaces/IAddressUid.cs delete mode 100644 src-examples/ProxyInterfaceConsumerForAkka/Interfaces/ILocalActorRefProvider.cs delete mode 100644 src-examples/ProxyInterfaceConsumerForAkka/Program.cs delete mode 100644 src-examples/ProxyInterfaceConsumerForAkka/ProxyInterfaceConsumerForAkka.csproj delete mode 100644 src/Speckle.ProxyGenerator/FileGenerators/ProxyClassesGenerator.AutoMapper.cs create mode 100644 tests/ProxyInterfaceSourceGeneratorTests/ProxyInterfaceSourceGeneratorTest.GenerateFiles_ForClassWith_BaseInterface.verified.txt create mode 100644 tests/ProxyInterfaceSourceGeneratorTests/ProxyInterfaceSourceGeneratorTest.GenerateFiles_ForClassWith_Extended.verified.txt create mode 100644 tests/ProxyInterfaceSourceGeneratorTests/Source/Foo3.cs create mode 100644 tests/ProxyInterfaceSourceGeneratorTests/Source/IBar3.cs create mode 100644 tests/ProxyInterfaceSourceGeneratorTests/Source/IBar3Proxy.cs create mode 100644 tests/ProxyInterfaceSourceGeneratorTests/Source/IFoo3.cs create mode 100644 tests/ProxyInterfaceSourceGeneratorTests/Source/IFoo3Proxy.cs diff --git a/README.md b/README.md index 9f901ae..7f50e36 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,36 @@ -# ProxyInterfaceGenerator +# Speckle.ProxyGenerator + +This is a fork of a library that almost gets us there but needed some new functionality to achieve a goal: successfully wrap a library we cannot modify and have interfaces in a separate assembly. + +Modifications have been mainly due that the primary interfaces need to be in a different assembly. + +## Usage so far + +Interface Assembly: + +- Base interfaces usable by anyone and Unit tests + +Api Assembly: + +- Proxy Interfaces that inherit from the base interfaces +- Proxy attribute references wrapped Api + +New needs: base interface is used by wrappers. Need to ignore members from wrapped api on demand. + +## Old Docs + This project uses Source Generation to generate an interface and a Proxy class for classes. This makes it possible to wrap external classes which do not have an interface, in a Proxy class which makes it easier to Mock and use DI. It supports: + - properties - methods - events - implicit and explicit operators ## Install + [![NuGet Badge](https://buildstats.info/nuget/ProxyInterfaceGenerator)](https://www.nuget.org/packages/ProxyInterfaceGenerator) You can install from NuGet using the following command in the package manager window: @@ -20,7 +42,9 @@ Or via the Visual Studio NuGet package manager or if you use the `dotnet` comman `dotnet add package ProxyInterfaceGenerator` ## Usage + ### Given: an external existing class which does not implement an interface + ``` c# public sealed class Person { @@ -34,6 +58,7 @@ public sealed class Person ``` ### Create a partial interface + And annotate this with `ProxyInterfaceGenerator.Proxy[...]` and with the Type which needs to be wrapped: ``` c# @@ -44,6 +69,7 @@ public partial interface IPerson ``` #### ProxyBaseClasses + In case also want to proxy the properties/methods/events from the base class(es), use this: ``` c# @@ -54,6 +80,7 @@ public partial interface IPerson ``` #### ProxyClassAccessibility + By default, the generated Proxy class is `public`. If you want to create the Proxy class as `internal`, use the following: ``` c# @@ -66,7 +93,9 @@ public partial interface IPerson ### When the code is compiled, this source generator creates the following #### :one: An additional partial interface + Which defines the same properties and methods as in the external class. + ``` c# public partial interface IPerson { @@ -77,6 +106,7 @@ public partial interface IPerson ``` #### :two: A Proxy class + Which takes the external class in the constructor and wraps all public properties, events and methods. ``` c# @@ -104,6 +134,7 @@ public class PersonProxy : IPerson :star: By default the accessibility from the generated Proxy class is `public`. ### :three: Use it + ``` c# IPerson p = new PersonProxy(new Person()); p.Name = "test"; @@ -111,4 +142,5 @@ p.HelloWorld("stef"); ``` # References -- https://route2roslyn.netlify.app/symbols-for-dummies/ \ No newline at end of file + +- diff --git a/Speckle.ProxyGenerator.sln b/Speckle.ProxyGenerator.sln index 971f104..a6e6b85 100644 --- a/Speckle.ProxyGenerator.sln +++ b/Speckle.ProxyGenerator.sln @@ -29,8 +29,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProxyInterfaceSourceGenerat EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProxyInterfaceConsumerForPnP", "src-examples\ProxyInterfaceConsumerForPnP\ProxyInterfaceConsumerForPnP.csproj", "{5F7DA2C5-B908-4B57-9F5F-BADF1216D89C}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProxyInterfaceConsumerForAkka", "src-examples\ProxyInterfaceConsumerForAkka\ProxyInterfaceConsumerForAkka.csproj", "{590908DF-A813-467A-94E4-3500020D0D54}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProxyInterfaceConsumerViaNuGet", "src-examples\ProxyInterfaceConsumerViaNuGet\ProxyInterfaceConsumerViaNuGet.csproj", "{1EA000E4-6103-4577-8D98-BDDA3BE458A2}" EndProject Global @@ -63,12 +61,6 @@ Global {5F7DA2C5-B908-4B57-9F5F-BADF1216D89C}.DebugAttach|Any CPU.Build.0 = Debug|Any CPU {5F7DA2C5-B908-4B57-9F5F-BADF1216D89C}.Release|Any CPU.ActiveCfg = Release|Any CPU {5F7DA2C5-B908-4B57-9F5F-BADF1216D89C}.Release|Any CPU.Build.0 = Release|Any CPU - {590908DF-A813-467A-94E4-3500020D0D54}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {590908DF-A813-467A-94E4-3500020D0D54}.Debug|Any CPU.Build.0 = Debug|Any CPU - {590908DF-A813-467A-94E4-3500020D0D54}.DebugAttach|Any CPU.ActiveCfg = Debug|Any CPU - {590908DF-A813-467A-94E4-3500020D0D54}.DebugAttach|Any CPU.Build.0 = Debug|Any CPU - {590908DF-A813-467A-94E4-3500020D0D54}.Release|Any CPU.ActiveCfg = Release|Any CPU - {590908DF-A813-467A-94E4-3500020D0D54}.Release|Any CPU.Build.0 = Release|Any CPU {1EA000E4-6103-4577-8D98-BDDA3BE458A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1EA000E4-6103-4577-8D98-BDDA3BE458A2}.Debug|Any CPU.Build.0 = Debug|Any CPU {1EA000E4-6103-4577-8D98-BDDA3BE458A2}.DebugAttach|Any CPU.ActiveCfg = Debug|Any CPU @@ -84,7 +76,6 @@ Global {7E0A10EE-CCC3-4281-9541-B0AF037D3DF9} = {38BA087F-EDA1-4F8A-A140-85B84791B815} {1BDB9046-D6D1-4FB4-AAB5-F24E33EEAE0A} = {19009F5B-3267-45E2-A8B6-89F2AB47D72C} {5F7DA2C5-B908-4B57-9F5F-BADF1216D89C} = {38BA087F-EDA1-4F8A-A140-85B84791B815} - {590908DF-A813-467A-94E4-3500020D0D54} = {38BA087F-EDA1-4F8A-A140-85B84791B815} {1EA000E4-6103-4577-8D98-BDDA3BE458A2} = {38BA087F-EDA1-4F8A-A140-85B84791B815} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/src-examples/ProxyInterfaceConsumer/Http/IHttpClient.cs b/src-examples/ProxyInterfaceConsumer/Http/IHttpClient.cs index 85f03e5..e3052f4 100644 --- a/src-examples/ProxyInterfaceConsumer/Http/IHttpClient.cs +++ b/src-examples/ProxyInterfaceConsumer/Http/IHttpClient.cs @@ -1,8 +1,9 @@ using System.Net.Http; +using Speckle.ProxyGenerator; namespace ProxyInterfaceConsumer.Http; -[Speckle.ProxyGenerator.Proxy(typeof(HttpClient), true)] +[Speckle.ProxyGenerator.Proxy(typeof(HttpClient), ImplementationOptions.ProxyBaseClasses)] public partial interface IHttpClient : IHttpMessageInvoker { } [Speckle.ProxyGenerator.Proxy(typeof(HttpMessageInvoker))] diff --git a/src-examples/ProxyInterfaceConsumer/IAddress.cs b/src-examples/ProxyInterfaceConsumer/IAddress.cs index 57e5c7d..4481daa 100644 --- a/src-examples/ProxyInterfaceConsumer/IAddress.cs +++ b/src-examples/ProxyInterfaceConsumer/IAddress.cs @@ -2,7 +2,7 @@ using Speckle.ProxyGenerator; namespace ProxyInterfaceConsumer { - [Proxy(typeof(Address), false, ProxyClassAccessibility.Public, new[] { "Weird" })] + [Proxy(typeof(Address), ImplementationOptions.ProxyBaseClasses, ProxyClassAccessibility.Public, new[] { "Weird" })] public partial interface IAddress { public void Weird() diff --git a/src-examples/ProxyInterfaceConsumer/ProxyInterfaceConsumer.csproj b/src-examples/ProxyInterfaceConsumer/ProxyInterfaceConsumer.csproj index 313865e..68e5230 100644 --- a/src-examples/ProxyInterfaceConsumer/ProxyInterfaceConsumer.csproj +++ b/src-examples/ProxyInterfaceConsumer/ProxyInterfaceConsumer.csproj @@ -4,6 +4,7 @@ net8.0 Exe enable + true @@ -12,7 +13,6 @@ - all diff --git a/src-examples/ProxyInterfaceConsumerForAkka/Interfaces/IAddressUid.cs b/src-examples/ProxyInterfaceConsumerForAkka/Interfaces/IAddressUid.cs deleted file mode 100644 index d719b5b..0000000 --- a/src-examples/ProxyInterfaceConsumerForAkka/Interfaces/IAddressUid.cs +++ /dev/null @@ -1,7 +0,0 @@ -using Akka.Remote; - -// namespace ProxyInterfaceConsumerForAkka.Interfaces; <-- no namespace - -[Speckle.ProxyGenerator.Proxy(typeof(AddressUid))] -// ReSharper disable once CheckNamespace -public partial interface IAddressUid { } diff --git a/src-examples/ProxyInterfaceConsumerForAkka/Interfaces/ILocalActorRefProvider.cs b/src-examples/ProxyInterfaceConsumerForAkka/Interfaces/ILocalActorRefProvider.cs deleted file mode 100644 index 506615c..0000000 --- a/src-examples/ProxyInterfaceConsumerForAkka/Interfaces/ILocalActorRefProvider.cs +++ /dev/null @@ -1,7 +0,0 @@ -using Akka.Actor; - -namespace ProxyInterfaceConsumerForAkka.Interfaces -{ - [Speckle.ProxyGenerator.Proxy(typeof(LocalActorRefProvider))] - public partial interface ILocalActorRefProvider { } -} diff --git a/src-examples/ProxyInterfaceConsumerForAkka/Program.cs b/src-examples/ProxyInterfaceConsumerForAkka/Program.cs deleted file mode 100644 index 4849601..0000000 --- a/src-examples/ProxyInterfaceConsumerForAkka/Program.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Diagnostics.CodeAnalysis; -using Akka.Actor; -using ProxyInterfaceConsumerForAkka.Interfaces; - -namespace ProxyInterfaceConsumerForAkka; - -public class Program -{ - [SuppressMessage("ReSharper", "NullableWarningSuppressionIsUsed")] - public static void Main() - { - Akka.Remote.AddressUid auid = null!; - IAddressUid addressUidProxy = new AddressUidProxy(auid); - - LocalActorRefProvider p = null!; - ILocalActorRefProvider proxy = new LocalActorRefProviderProxy(p); - } -} diff --git a/src-examples/ProxyInterfaceConsumerForAkka/ProxyInterfaceConsumerForAkka.csproj b/src-examples/ProxyInterfaceConsumerForAkka/ProxyInterfaceConsumerForAkka.csproj deleted file mode 100644 index 7aaee03..0000000 --- a/src-examples/ProxyInterfaceConsumerForAkka/ProxyInterfaceConsumerForAkka.csproj +++ /dev/null @@ -1,30 +0,0 @@ - - - - net8.0 - Exe - enable - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - - - - diff --git a/src-examples/ProxyInterfaceConsumerForPnP/ProxyInterfaceConsumerForPnP.csproj b/src-examples/ProxyInterfaceConsumerForPnP/ProxyInterfaceConsumerForPnP.csproj index 20c1884..8972d64 100644 --- a/src-examples/ProxyInterfaceConsumerForPnP/ProxyInterfaceConsumerForPnP.csproj +++ b/src-examples/ProxyInterfaceConsumerForPnP/ProxyInterfaceConsumerForPnP.csproj @@ -7,7 +7,6 @@ - all diff --git a/src-examples/ProxyInterfaceConsumerViaNuGet/ProxyInterfaceConsumerViaNuGet.csproj b/src-examples/ProxyInterfaceConsumerViaNuGet/ProxyInterfaceConsumerViaNuGet.csproj index d460741..1638286 100644 --- a/src-examples/ProxyInterfaceConsumerViaNuGet/ProxyInterfaceConsumerViaNuGet.csproj +++ b/src-examples/ProxyInterfaceConsumerViaNuGet/ProxyInterfaceConsumerViaNuGet.csproj @@ -10,7 +10,6 @@ - all diff --git a/src/Speckle.ProxyGenerator/Extensions/NamedTypeSymbolExtensions.cs b/src/Speckle.ProxyGenerator/Extensions/NamedTypeSymbolExtensions.cs index ac1c9b3..859578c 100644 --- a/src/Speckle.ProxyGenerator/Extensions/NamedTypeSymbolExtensions.cs +++ b/src/Speckle.ProxyGenerator/Extensions/NamedTypeSymbolExtensions.cs @@ -48,7 +48,8 @@ internal static class NamedTypeSymbolExtensions public static List ResolveImplementedInterfaces( this INamedTypeSymbol symbol, - bool proxyBaseClasses + bool proxyBaseClasses, + bool proxyInterfaces ) { // Members implemented by us or base classes should go here. @@ -58,7 +59,11 @@ internal static class NamedTypeSymbolExtensions .ToList(); // Direct interfaces, recursive interfaces or base class interfaces should go here. - var interfaces = new List(symbol.Interfaces); + var interfaces = new List(); + if (proxyInterfaces) + { + interfaces.AddRange(symbol.Interfaces); + } var baseType = symbol.BaseType; while ( proxyBaseClasses @@ -69,7 +74,10 @@ internal static class NamedTypeSymbolExtensions publicMembers.AddRange( baseType.GetMembers().Where(m => m.DeclaredAccessibility == Accessibility.Public) ); - interfaces.AddRange(baseType.Interfaces); + if (proxyInterfaces) + { + interfaces.AddRange(baseType.Interfaces); + } baseType = baseType.BaseType; } @@ -100,4 +108,13 @@ internal static class NamedTypeSymbolExtensions return realizedInterfaces; } + + public static IEnumerable ResolveBaseInterfaces( + this INamedTypeSymbol symbol, List previousInterfaces + ) + { + // Direct interfaces, recursive interfaces or base class interfaces should go here. + var interfaces = new List(symbol.Interfaces); + return interfaces.Except(previousInterfaces); + } } diff --git a/src/Speckle.ProxyGenerator/FileGenerators/BaseGenerator.cs b/src/Speckle.ProxyGenerator/FileGenerators/BaseGenerator.cs index 3e1815e..dd585bb 100644 --- a/src/Speckle.ProxyGenerator/FileGenerators/BaseGenerator.cs +++ b/src/Speckle.ProxyGenerator/FileGenerators/BaseGenerator.cs @@ -11,6 +11,7 @@ namespace Speckle.ProxyGenerator.FileGenerators; internal abstract class BaseGenerator { + protected const string globalPrefix = "global::"; protected readonly Context Context; protected readonly bool SupportsNullable; @@ -35,6 +36,11 @@ internal abstract class BaseGenerator [NotNullWhen(true)] out ProxyData? proxyData ) { + proxyData = Context.Candidates.Values.FirstOrDefault(x => x.FullQualifiedMappedTypeName == type); + if (proxyData is not null) + { + return true; + } proxyData = Context.Candidates.Values.FirstOrDefault(x => x.FullQualifiedTypeName == type); return proxyData != null; } @@ -214,7 +220,6 @@ internal abstract class BaseGenerator ) { classSymbol = default; - const string globalPrefix = "global::"; if (name.StartsWith(globalPrefix, StringComparison.Ordinal)) { name = name.Substring(globalPrefix.Length); @@ -283,8 +288,7 @@ internal abstract class BaseGenerator } protected IReadOnlyList GetExtendsProxyData( - ProxyData proxyData, - ClassSymbol targetClassSymbol + ClassSymbol targetClassSymbol, bool useFullQualifiedMappedTypeName ) { var extendsProxyClasses = new List(); @@ -293,10 +297,22 @@ internal abstract class BaseGenerator var candidate = Context.Candidates.Values.FirstOrDefault(ci => ci.FullQualifiedTypeName == baseType.ToFullyQualifiedDisplayString() ); - if (candidate is not null) + if (useFullQualifiedMappedTypeName) { - extendsProxyClasses.Add(candidate); - break; + //is a candidate and overrides + if (candidate?.FullQualifiedMappedTypeName != null) + { + extendsProxyClasses.Add(candidate); + break; + } + } + else + { + if (candidate != null) + { + extendsProxyClasses.Add(candidate); + break; + } } } return extendsProxyClasses; diff --git a/src/Speckle.ProxyGenerator/FileGenerators/ExtraFilesGenerator.cs b/src/Speckle.ProxyGenerator/FileGenerators/ExtraFilesGenerator.cs index 3f0b8ab..829d02d 100644 --- a/src/Speckle.ProxyGenerator/FileGenerators/ExtraFilesGenerator.cs +++ b/src/Speckle.ProxyGenerator/FileGenerators/ExtraFilesGenerator.cs @@ -29,34 +29,38 @@ namespace Speckle.ProxyGenerator internal sealed class ProxyAttribute : Attribute {{ public Type Type {{ get; }} - public bool ProxyBaseClasses {{ get; }} + public ImplementationOptions Options {{ get; }} public ProxyClassAccessibility Accessibility {{ get; }} public string[]? MembersToIgnore {{ get; }} - public ProxyAttribute(Type type) : this(type, false, ProxyClassAccessibility.Public) + public ProxyAttribute(Type type) : this(type, ImplementationOptions.None, ProxyClassAccessibility.Public) {{ }} - public ProxyAttribute(Type type, bool proxyBaseClasses) : this(type, proxyBaseClasses, ProxyClassAccessibility.Public) + public ProxyAttribute(Type type, ImplementationOptions options) : this(type, options, ProxyClassAccessibility.Public) {{ }} - public ProxyAttribute(Type type, ProxyClassAccessibility accessibility) : this(type, false, accessibility) + public ProxyAttribute(Type type, ProxyClassAccessibility accessibility) : this(type, ImplementationOptions.None, accessibility) {{ }} - public ProxyAttribute(Type type, bool proxyBaseClasses, ProxyClassAccessibility accessibility) : this(type, proxyBaseClasses, accessibility, null) + public ProxyAttribute(Type type, ImplementationOptions options, ProxyClassAccessibility accessibility) : this(type, options, accessibility, null) {{ }} - public ProxyAttribute(Type type, string[]? membersToIgnore) : this(type, false, ProxyClassAccessibility.Public, null) + public ProxyAttribute(Type type, string[]? membersToIgnore) : this(type, ImplementationOptions.None, ProxyClassAccessibility.Public, null) {{ }} - public ProxyAttribute(Type type, bool proxyBaseClasses, ProxyClassAccessibility accessibility, string[]? membersToIgnore) + public ProxyAttribute(Type type, ImplementationOptions options, string[]? membersToIgnore) : this(type, options, ProxyClassAccessibility.Public, null) + {{ + }} + + public ProxyAttribute(Type type, ImplementationOptions options, ProxyClassAccessibility accessibility, string[]? membersToIgnore) {{ Type = type; - ProxyBaseClasses = proxyBaseClasses; + Options = options; Accessibility = accessibility; MembersToIgnore = membersToIgnore; }} @@ -69,6 +73,19 @@ namespace Speckle.ProxyGenerator Internal = 1 }} + [Flags] + internal enum ImplementationOptions + {{ + None = 0, + + ProxyBaseClasses = 1, + + ProxyInterfaces = 2, + + UseExtendedInterfaces = 4, + + ProxyForBaseInterface = 8 + }} {supportsNullable.IIf("#nullable restore")} }}" ); diff --git a/src/Speckle.ProxyGenerator/FileGenerators/PartialInterfacesGenerator.cs b/src/Speckle.ProxyGenerator/FileGenerators/PartialInterfacesGenerator.cs index 490be1c..901182c 100644 --- a/src/Speckle.ProxyGenerator/FileGenerators/PartialInterfacesGenerator.cs +++ b/src/Speckle.ProxyGenerator/FileGenerators/PartialInterfacesGenerator.cs @@ -5,14 +5,14 @@ using Microsoft.CodeAnalysis.CSharp.Syntax; using Speckle.ProxyGenerator.Enums; using Speckle.ProxyGenerator.Extensions; using Speckle.ProxyGenerator.Models; +using Speckle.ProxyGenerator.Types; using Speckle.ProxyGenerator.Utils; namespace Speckle.ProxyGenerator.FileGenerators; internal class PartialInterfacesGenerator : BaseGenerator, IFilesGenerator { - private IReadOnlyCollection _implementedInterfaces = - new List(); + private List _implementedInterfaces = new(); public PartialInterfacesGenerator(Context context, bool supportsNullable) : base(context, supportsNullable) { } @@ -67,7 +67,7 @@ internal class PartialInterfacesGenerator : BaseGenerator, IFilesGenerator fileData = new FileData( $"{sourceInterfaceSymbol.Symbol.GetFullMetadataName()}.g.cs", - CreatePartialInterfaceCode(pd.Namespace, targetClassSymbol, interfaceName, pd) + CreatePartialInterfaceCode(pd.Namespace, targetClassSymbol, sourceInterfaceSymbol,interfaceName, pd) ); return true; @@ -76,21 +76,41 @@ internal class PartialInterfacesGenerator : BaseGenerator, IFilesGenerator private string CreatePartialInterfaceCode( string ns, ClassSymbol classSymbol, + ClassSymbol interfaceSymbol, string interfaceName, ProxyData proxyData ) { - var extendsProxyClasses = GetExtendsProxyData(proxyData, classSymbol); - _implementedInterfaces = classSymbol.Symbol.ResolveImplementedInterfaces( - proxyData.ProxyBaseClasses - ); + _implementedInterfaces.Clear(); + _implementedInterfaces.AddRange(classSymbol.Symbol.ResolveImplementedInterfaces( + proxyData.Options.HasFlag(ImplementationOptions.ProxyBaseClasses), + proxyData.Options.HasFlag(ImplementationOptions.ProxyInterfaces) + )); + if (proxyData.Options.HasFlag(ImplementationOptions.UseExtendedInterfaces)) + { + var bases = interfaceSymbol.Symbol.ResolveBaseInterfaces(_implementedInterfaces).ToList(); + if (bases.Count == 1 && proxyData.Options.HasFlag(ImplementationOptions.ProxyForBaseInterface)) + { + proxyData.FullQualifiedMappedTypeName = globalPrefix + bases.Single().GetFullMetadataName(); + } + _implementedInterfaces.AddRange(bases); + //don't readd self + if (_implementedInterfaces.Contains(interfaceSymbol.Symbol)) + { + _implementedInterfaces.Remove(interfaceSymbol.Symbol); + } + } + + _implementedInterfaces = _implementedInterfaces.Distinct().ToList(); + var isNew = GetExtendsProxyData(classSymbol, proxyData.Options.HasFlag(ImplementationOptions.UseExtendedInterfaces)).Any(); + var implementedInterfacesNames = _implementedInterfaces .Select(i => i.ToFullyQualifiedDisplayString()) .ToArray(); var implements = implementedInterfacesNames.Any() ? $" : {string.Join(", ", implementedInterfacesNames)}" : string.Empty; - var @new = extendsProxyClasses.Any() ? "new " : string.Empty; + var @new = isNew ? "new " : string.Empty; var (namespaceStart, namespaceEnd) = NamespaceBuilder.Build(ns); var events = GenerateEvents(classSymbol, proxyData); var properties = GenerateProperties(classSymbol, proxyData); @@ -98,7 +118,7 @@ internal class PartialInterfacesGenerator : BaseGenerator, IFilesGenerator return $@"//---------------------------------------------------------------------------------------- // -// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// This code was generated by https://github.com/specklesystems/ProxyGenerator. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/src/Speckle.ProxyGenerator/FileGenerators/ProxyClassesGenerator.AutoMapper.cs b/src/Speckle.ProxyGenerator/FileGenerators/ProxyClassesGenerator.AutoMapper.cs deleted file mode 100644 index a7708f1..0000000 --- a/src/Speckle.ProxyGenerator/FileGenerators/ProxyClassesGenerator.AutoMapper.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System.Text; -using Speckle.ProxyGenerator.Extensions; - -namespace Speckle.ProxyGenerator.FileGenerators; - -internal partial class ProxyClassesGenerator -{ - private static string GeneratePrivateAutoMapper() - { - return " private readonly IMapper _mapper;"; - } - - private string GenerateMapperConfigurationForAutoMapper() - { - var str = new StringBuilder(); - - str.AppendLine(" _mapper = new MapperConfiguration(cfg =>"); - str.AppendLine(" {"); - foreach (var replacedType in Context.ReplacedTypes) - { - TryFindProxyDataByTypeName(replacedType.Key, out var fullTypeName); - var classNameProxy = - $"{fullTypeName!.NamespaceDot}{fullTypeName.ShortMetadataName}Proxy"; - - var instance = - $"instance{(replacedType.Key + replacedType.Value).GetDeterministicHashCodeAsString()}"; - var proxy = - $"proxy{(replacedType.Value + replacedType.Key).GetDeterministicHashCodeAsString()}"; - - str.AppendLine( - $" cfg.CreateMap<{replacedType.Key}, {replacedType.Value}>().ConstructUsing({instance} => new {classNameProxy}({instance}));" - ); - str.AppendLine( - $" cfg.CreateMap<{replacedType.Value}, {replacedType.Key}>().ConstructUsing({proxy} => (({classNameProxy}) {proxy})._Instance);" - ); - str.AppendLine(); - } - str.AppendLine(" }).CreateMapper();"); - - return str.ToString(); - } -} diff --git a/src/Speckle.ProxyGenerator/FileGenerators/ProxyClassesGenerator.cs b/src/Speckle.ProxyGenerator/FileGenerators/ProxyClassesGenerator.cs index 928d2cc..f631082 100644 --- a/src/Speckle.ProxyGenerator/FileGenerators/ProxyClassesGenerator.cs +++ b/src/Speckle.ProxyGenerator/FileGenerators/ProxyClassesGenerator.cs @@ -54,7 +54,7 @@ internal partial class ProxyClassesGenerator : BaseGenerator, IFilesGenerator var className = targetClassSymbol.Symbol.ResolveProxyClassName(); var constructorName = $"{targetClassSymbol.Symbol.Name}Proxy"; - var extendsProxyClasses = GetExtendsProxyData(pd, targetClassSymbol); + var extendsProxyClasses = GetExtendsProxyData(targetClassSymbol, false); fileData = new FileData( $"{targetClassSymbol.Symbol.GetFullMetadataName()}Proxy.g.cs", @@ -117,7 +117,7 @@ internal partial class ProxyClassesGenerator : BaseGenerator, IFilesGenerator return $@"//---------------------------------------------------------------------------------------- // -// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// This code was generated by https://github.com/specklesystems/ProxyGenerator. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/src/Speckle.ProxyGenerator/Models/ProxyData.cs b/src/Speckle.ProxyGenerator/Models/ProxyData.cs index 4404123..b62fb95 100644 --- a/src/Speckle.ProxyGenerator/Models/ProxyData.cs +++ b/src/Speckle.ProxyGenerator/Models/ProxyData.cs @@ -10,18 +10,20 @@ internal class ProxyData public string ShortInterfaceName { get; } - public string FullInterfaceName { get; } + private string _fullInterfaceName; + public string FullInterfaceName => FullQualifiedMappedTypeName ?? _fullInterfaceName; public string FullQualifiedTypeName { get; } + public string? FullQualifiedMappedTypeName { get; set; } + public string ShortMetadataName { get; } public string FullMetadataTypeName { get; } public List Usings { get; } - public bool ProxyBaseClasses { get; } - + public ImplementationOptions Options { get; } public ProxyClassAccessibility Accessibility { get; } public string[] MembersToIgnore { get; } @@ -34,7 +36,7 @@ internal class ProxyData string shortMetadataTypeName, string fullMetadataTypeName, List usings, - bool proxyBaseClasses, + ImplementationOptions options, ProxyClassAccessibility accessibility, string[] membersToIgnore ) @@ -43,7 +45,7 @@ internal class ProxyData NamespaceDot = namespaceDot ?? throw new ArgumentNullException(nameof(namespaceDot)); ShortInterfaceName = shortInterfaceName ?? throw new ArgumentNullException(nameof(shortInterfaceName)); - FullInterfaceName = + _fullInterfaceName = fullInterfaceName ?? throw new ArgumentNullException(nameof(fullInterfaceName)); FullQualifiedTypeName = fullQualifiedTypeName ?? throw new ArgumentNullException(nameof(fullQualifiedTypeName)); @@ -52,7 +54,7 @@ internal class ProxyData FullMetadataTypeName = fullMetadataTypeName ?? throw new ArgumentNullException(nameof(fullMetadataTypeName)); Usings = usings ?? throw new ArgumentNullException(nameof(usings)); - ProxyBaseClasses = proxyBaseClasses; + Options = options; Accessibility = accessibility; MembersToIgnore = membersToIgnore; } diff --git a/src/Speckle.ProxyGenerator/Speckle.ProxyGenerator.csproj b/src/Speckle.ProxyGenerator/Speckle.ProxyGenerator.csproj index aafcecb..8bd3432 100644 --- a/src/Speckle.ProxyGenerator/Speckle.ProxyGenerator.csproj +++ b/src/Speckle.ProxyGenerator/Speckle.ProxyGenerator.csproj @@ -1,7 +1,7 @@ - 0.1.2 + 0.1.5 netstandard2.0 Latest enable diff --git a/src/Speckle.ProxyGenerator/SyntaxReceiver/AttributeArgumentListParser.cs b/src/Speckle.ProxyGenerator/SyntaxReceiver/AttributeArgumentListParser.cs index 3e72290..ab2b8f5 100644 --- a/src/Speckle.ProxyGenerator/SyntaxReceiver/AttributeArgumentListParser.cs +++ b/src/Speckle.ProxyGenerator/SyntaxReceiver/AttributeArgumentListParser.cs @@ -48,34 +48,20 @@ internal static class AttributeArgumentListParser result = result with { MembersToIgnore = membersToIgnore }; continue; } - if (TryParseAsBoolean(argument.Expression, out var proxyBaseClasses)) - { - result = result with { ProxyBaseClasses = proxyBaseClasses }; - continue; - } - if (TryParseAsEnum(argument.Expression, out var accessibility)) { result = result with { Accessibility = accessibility }; } + + if (TryParseAsEnum(argument.Expression, out var options)) + { + result = result with { Options = options }; + } } return result; } - private static bool TryParseAsBoolean(ExpressionSyntax expressionSyntax, out bool value) - { - value = default; - - if (expressionSyntax is LiteralExpressionSyntax literalExpressionSyntax) - { - value = literalExpressionSyntax.Kind() == SyntaxKind.TrueLiteralExpression; - return true; - } - - return false; - } - private static bool TryParseAsType( ExpressionSyntax expressionSyntax, SemanticModel semanticModel, @@ -100,22 +86,27 @@ internal static class AttributeArgumentListParser } private static bool TryParseAsEnum(ExpressionSyntax expressionSyntax, out TEnum value) - where TEnum : struct + where TEnum : struct, Enum { var enumAsString = expressionSyntax.ToString(); - if ( - enumAsString.Length > typeof(TEnum).Name.Length - && Enum.TryParse( - expressionSyntax.ToString().Substring(typeof(TEnum).Name.Length + 1), - out value - ) - ) - { - return true; - } - value = default; - return false; + if (!enumAsString.Contains(typeof(TEnum).Name)) + { + return false; + } + var splitter = new[] {$"{typeof(TEnum).Name}."}; + var vals = enumAsString.Split(splitter, StringSplitOptions.RemoveEmptyEntries).Select(x => x.TrimEnd(' ', '|')); + + long l = 0; + foreach (var v in vals) + { + if (Enum.TryParse(v, out var e)) + { + l |= Convert.ToInt64(e); + } + } + value = (TEnum)Enum.ToObject(typeof(TEnum), l);; + return true; } private static bool TryParseAsStringArray(ExpressionSyntax expressionSyntax, out string[] value) diff --git a/src/Speckle.ProxyGenerator/SyntaxReceiver/ProxySyntaxReceiver.cs b/src/Speckle.ProxyGenerator/SyntaxReceiver/ProxySyntaxReceiver.cs index 19fc888..8c299e5 100644 --- a/src/Speckle.ProxyGenerator/SyntaxReceiver/ProxySyntaxReceiver.cs +++ b/src/Speckle.ProxyGenerator/SyntaxReceiver/ProxySyntaxReceiver.cs @@ -99,7 +99,7 @@ internal class ProxySyntaxReceiver : ISyntaxContextReceiver fullMetadataTypeName: metadataName, shortMetadataTypeName: metadataName.Split('.').Last(), usings: usings, - proxyBaseClasses: fluentBuilderAttributeArguments.ProxyBaseClasses, + options: fluentBuilderAttributeArguments.Options, accessibility: fluentBuilderAttributeArguments.Accessibility, membersToIgnore: fluentBuilderAttributeArguments.MembersToIgnore ); diff --git a/src/Speckle.ProxyGenerator/Types/FluentBuilderAttributeArguments.cs b/src/Speckle.ProxyGenerator/Types/FluentBuilderAttributeArguments.cs index aed4b5e..779704f 100644 --- a/src/Speckle.ProxyGenerator/Types/FluentBuilderAttributeArguments.cs +++ b/src/Speckle.ProxyGenerator/Types/FluentBuilderAttributeArguments.cs @@ -5,7 +5,7 @@ internal record ProxyInterfaceGeneratorAttributeArguments( string MetadataName ) { - public bool ProxyBaseClasses { get; set; } + public ImplementationOptions Options { get; set; } public ProxyClassAccessibility Accessibility { get; set; } public string[] MembersToIgnore { get; set; } = []; diff --git a/src/Speckle.ProxyGenerator/Types/ProxyInterfaceGeneratorAccessibility.cs b/src/Speckle.ProxyGenerator/Types/ProxyInterfaceGeneratorAccessibility.cs index 9a8ef81..2ebf158 100644 --- a/src/Speckle.ProxyGenerator/Types/ProxyInterfaceGeneratorAccessibility.cs +++ b/src/Speckle.ProxyGenerator/Types/ProxyInterfaceGeneratorAccessibility.cs @@ -7,3 +7,17 @@ internal enum ProxyClassAccessibility Internal = 1 } + +[Flags] +internal enum ImplementationOptions +{ + None = 0, + + ProxyBaseClasses = 1, + + ProxyInterfaces = 2, + + UseExtendedInterfaces = 4, + + ProxyForBaseInterface = 8 +} diff --git a/src/Speckle.ProxyGenerator/Utils/MemberHelper.cs b/src/Speckle.ProxyGenerator/Utils/MemberHelper.cs index 30267f8..dac7d3a 100644 --- a/src/Speckle.ProxyGenerator/Utils/MemberHelper.cs +++ b/src/Speckle.ProxyGenerator/Utils/MemberHelper.cs @@ -1,5 +1,6 @@ using Microsoft.CodeAnalysis; using Speckle.ProxyGenerator.Models; +using Speckle.ProxyGenerator.Types; namespace Speckle.ProxyGenerator.Utils; @@ -108,7 +109,7 @@ internal static class MemberHelper var ownMembers = membersQuery.ToList(); var ownMemberNames = ownMembers.Select(x => x.Name); - if (!proxyData.ProxyBaseClasses) + if (!proxyData.Options.HasFlag(ImplementationOptions.ProxyBaseClasses)) { return ownMembers; } diff --git a/tests/ProxyInterfaceSourceGeneratorTests/AkkaTests.cs b/tests/ProxyInterfaceSourceGeneratorTests/AkkaTests.cs index 354fc91..87e543a 100644 --- a/tests/ProxyInterfaceSourceGeneratorTests/AkkaTests.cs +++ b/tests/ProxyInterfaceSourceGeneratorTests/AkkaTests.cs @@ -35,7 +35,7 @@ public class AkkaTests AttributeToAddToInterface = new ExtraAttribute { Name = "Speckle.ProxyGenerator.Proxy", - ArgumentList = "typeof(Akka.Actor.LocalActorRefProvider)" + ArgumentList = new [] {"typeof(Akka.Actor.LocalActorRefProvider)","ImplementationOptions.ProxyInterfaces"} } }; diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Destination/AkkaGenerated/Akka.Actor.LocalActorRefProviderProxy.g.cs b/tests/ProxyInterfaceSourceGeneratorTests/Destination/AkkaGenerated/Akka.Actor.LocalActorRefProviderProxy.g.cs index e78a399..c062e28 100644 --- a/tests/ProxyInterfaceSourceGeneratorTests/Destination/AkkaGenerated/Akka.Actor.LocalActorRefProviderProxy.g.cs +++ b/tests/ProxyInterfaceSourceGeneratorTests/Destination/AkkaGenerated/Akka.Actor.LocalActorRefProviderProxy.g.cs @@ -1,6 +1,6 @@ //---------------------------------------------------------------------------------------- // -// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// This code was generated by https://github.com/specklesystems/ProxyGenerator. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Destination/AkkaGenerated/ProxyInterfaceSourceGeneratorTests.Source.AkkaActor.ILocalActorRefProvider.g.cs b/tests/ProxyInterfaceSourceGeneratorTests/Destination/AkkaGenerated/ProxyInterfaceSourceGeneratorTests.Source.AkkaActor.ILocalActorRefProvider.g.cs index d9d1715..6a50d5c 100644 --- a/tests/ProxyInterfaceSourceGeneratorTests/Destination/AkkaGenerated/ProxyInterfaceSourceGeneratorTests.Source.AkkaActor.ILocalActorRefProvider.g.cs +++ b/tests/ProxyInterfaceSourceGeneratorTests/Destination/AkkaGenerated/ProxyInterfaceSourceGeneratorTests.Source.AkkaActor.ILocalActorRefProvider.g.cs @@ -1,6 +1,6 @@ //---------------------------------------------------------------------------------------- // -// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// This code was generated by https://github.com/specklesystems/ProxyGenerator. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Destination/INoNamespace.g.cs b/tests/ProxyInterfaceSourceGeneratorTests/Destination/INoNamespace.g.cs index fc6a528..6f07b4d 100644 --- a/tests/ProxyInterfaceSourceGeneratorTests/Destination/INoNamespace.g.cs +++ b/tests/ProxyInterfaceSourceGeneratorTests/Destination/INoNamespace.g.cs @@ -1,6 +1,6 @@ //---------------------------------------------------------------------------------------- // -// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// This code was generated by https://github.com/specklesystems/ProxyGenerator. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Destination/Microsoft.SharePoint.Client.ClientContextProxy.g.cs b/tests/ProxyInterfaceSourceGeneratorTests/Destination/Microsoft.SharePoint.Client.ClientContextProxy.g.cs index 72e0d28..20136c3 100644 --- a/tests/ProxyInterfaceSourceGeneratorTests/Destination/Microsoft.SharePoint.Client.ClientContextProxy.g.cs +++ b/tests/ProxyInterfaceSourceGeneratorTests/Destination/Microsoft.SharePoint.Client.ClientContextProxy.g.cs @@ -1,6 +1,6 @@ //---------------------------------------------------------------------------------------- // -// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// This code was generated by https://github.com/specklesystems/ProxyGenerator. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Destination/Microsoft.SharePoint.Client.ClientObjectProxy.g.cs b/tests/ProxyInterfaceSourceGeneratorTests/Destination/Microsoft.SharePoint.Client.ClientObjectProxy.g.cs index e63fdae..68773b5 100644 --- a/tests/ProxyInterfaceSourceGeneratorTests/Destination/Microsoft.SharePoint.Client.ClientObjectProxy.g.cs +++ b/tests/ProxyInterfaceSourceGeneratorTests/Destination/Microsoft.SharePoint.Client.ClientObjectProxy.g.cs @@ -1,6 +1,6 @@ //---------------------------------------------------------------------------------------- // -// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// This code was generated by https://github.com/specklesystems/ProxyGenerator. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Destination/Microsoft.SharePoint.Client.ClientRuntimeContextProxy.g.cs b/tests/ProxyInterfaceSourceGeneratorTests/Destination/Microsoft.SharePoint.Client.ClientRuntimeContextProxy.g.cs index cc60751..b6c2732 100644 --- a/tests/ProxyInterfaceSourceGeneratorTests/Destination/Microsoft.SharePoint.Client.ClientRuntimeContextProxy.g.cs +++ b/tests/ProxyInterfaceSourceGeneratorTests/Destination/Microsoft.SharePoint.Client.ClientRuntimeContextProxy.g.cs @@ -1,6 +1,6 @@ //---------------------------------------------------------------------------------------- // -// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// This code was generated by https://github.com/specklesystems/ProxyGenerator. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Destination/Microsoft.SharePoint.Client.SecurableObjectProxy.g.cs b/tests/ProxyInterfaceSourceGeneratorTests/Destination/Microsoft.SharePoint.Client.SecurableObjectProxy.g.cs index d509130..3be67cd 100644 --- a/tests/ProxyInterfaceSourceGeneratorTests/Destination/Microsoft.SharePoint.Client.SecurableObjectProxy.g.cs +++ b/tests/ProxyInterfaceSourceGeneratorTests/Destination/Microsoft.SharePoint.Client.SecurableObjectProxy.g.cs @@ -1,6 +1,6 @@ //---------------------------------------------------------------------------------------- // -// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// This code was generated by https://github.com/specklesystems/ProxyGenerator. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Destination/Microsoft.SharePoint.Client.WebProxy.g.cs b/tests/ProxyInterfaceSourceGeneratorTests/Destination/Microsoft.SharePoint.Client.WebProxy.g.cs index f4e8e49..27d4907 100644 --- a/tests/ProxyInterfaceSourceGeneratorTests/Destination/Microsoft.SharePoint.Client.WebProxy.g.cs +++ b/tests/ProxyInterfaceSourceGeneratorTests/Destination/Microsoft.SharePoint.Client.WebProxy.g.cs @@ -1,6 +1,6 @@ //---------------------------------------------------------------------------------------- // -// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// This code was generated by https://github.com/specklesystems/ProxyGenerator. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Destination/NoNamespaceProxy.g.cs b/tests/ProxyInterfaceSourceGeneratorTests/Destination/NoNamespaceProxy.g.cs index f888c26..4aabccf 100644 --- a/tests/ProxyInterfaceSourceGeneratorTests/Destination/NoNamespaceProxy.g.cs +++ b/tests/ProxyInterfaceSourceGeneratorTests/Destination/NoNamespaceProxy.g.cs @@ -1,6 +1,6 @@ //---------------------------------------------------------------------------------------- // -// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// This code was generated by https://github.com/specklesystems/ProxyGenerator. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Namespace1.ClassInNamespaceProxy.g.cs b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Namespace1.ClassInNamespaceProxy.g.cs index 8d015f6..d20befb 100644 --- a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Namespace1.ClassInNamespaceProxy.g.cs +++ b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Namespace1.ClassInNamespaceProxy.g.cs @@ -1,6 +1,6 @@ //---------------------------------------------------------------------------------------- // -// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// This code was generated by https://github.com/specklesystems/ProxyGenerator. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Namespace1.IClassInNamespace.g.cs b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Namespace1.IClassInNamespace.g.cs index 09a85ca..d004c54 100644 --- a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Namespace1.IClassInNamespace.g.cs +++ b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Namespace1.IClassInNamespace.g.cs @@ -1,6 +1,6 @@ //---------------------------------------------------------------------------------------- // -// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// This code was generated by https://github.com/specklesystems/ProxyGenerator. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Namespace2.ClassInNamespaceProxy.g.cs b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Namespace2.ClassInNamespaceProxy.g.cs index 0480f4b..b0677e7 100644 --- a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Namespace2.ClassInNamespaceProxy.g.cs +++ b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Namespace2.ClassInNamespaceProxy.g.cs @@ -1,6 +1,6 @@ //---------------------------------------------------------------------------------------- // -// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// This code was generated by https://github.com/specklesystems/ProxyGenerator. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Namespace2.IClassInNamespace.g.cs b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Namespace2.IClassInNamespace.g.cs index ddad4d3..d56afec 100644 --- a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Namespace2.IClassInNamespace.g.cs +++ b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Namespace2.IClassInNamespace.g.cs @@ -1,6 +1,6 @@ //---------------------------------------------------------------------------------------- // -// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// This code was generated by https://github.com/specklesystems/ProxyGenerator. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.Generic`1Proxy.g.cs b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.Generic`1Proxy.g.cs index 0e99042..54ecd75 100644 --- a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.Generic`1Proxy.g.cs +++ b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.Generic`1Proxy.g.cs @@ -1,6 +1,6 @@ //---------------------------------------------------------------------------------------- // -// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// This code was generated by https://github.com/specklesystems/ProxyGenerator. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.HumanProxy.g.cs b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.HumanProxy.g.cs index f093a59..35fca57 100644 --- a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.HumanProxy.g.cs +++ b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.HumanProxy.g.cs @@ -1,6 +1,6 @@ //---------------------------------------------------------------------------------------- // -// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// This code was generated by https://github.com/specklesystems/ProxyGenerator. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.IGeneric.g.cs b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.IGeneric.g.cs index 8b48a00..2501ef0 100644 --- a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.IGeneric.g.cs +++ b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.IGeneric.g.cs @@ -1,6 +1,6 @@ //---------------------------------------------------------------------------------------- // -// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// This code was generated by https://github.com/specklesystems/ProxyGenerator. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.IHttpClient.g.cs b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.IHttpClient.g.cs index 5e015dd..a90f30b 100644 --- a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.IHttpClient.g.cs +++ b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.IHttpClient.g.cs @@ -1,6 +1,6 @@ //---------------------------------------------------------------------------------------- // -// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// This code was generated by https://github.com/specklesystems/ProxyGenerator. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.IHttpMessageInvoker.g.cs b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.IHttpMessageInvoker.g.cs index 3008c32..ac552e8 100644 --- a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.IHttpMessageInvoker.g.cs +++ b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.IHttpMessageInvoker.g.cs @@ -1,6 +1,6 @@ //---------------------------------------------------------------------------------------- // -// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// This code was generated by https://github.com/specklesystems/ProxyGenerator. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -12,7 +12,7 @@ using System; namespace ProxyInterfaceSourceGeneratorTests.Source { - public partial interface IHttpMessageInvoker : global::System.IDisposable + public partial interface IHttpMessageInvoker { global::System.Net.Http.HttpMessageInvoker _Instance { get; } @@ -20,6 +20,8 @@ namespace ProxyInterfaceSourceGeneratorTests.Source global::System.Net.Http.HttpResponseMessage Send(global::System.Net.Http.HttpRequestMessage request, global::System.Threading.CancellationToken cancellationToken); global::System.Threading.Tasks.Task SendAsync(global::System.Net.Http.HttpRequestMessage request, global::System.Threading.CancellationToken cancellationToken); + + void Dispose(); } } #nullable restore \ No newline at end of file diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.IHuman.g.cs b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.IHuman.g.cs index f656769..ca36e9d 100644 --- a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.IHuman.g.cs +++ b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.IHuman.g.cs @@ -1,6 +1,6 @@ //---------------------------------------------------------------------------------------- // -// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// This code was generated by https://github.com/specklesystems/ProxyGenerator. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.IMixedVisibility.g.cs b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.IMixedVisibility.g.cs index 32e53e4..3878042 100644 --- a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.IMixedVisibility.g.cs +++ b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.IMixedVisibility.g.cs @@ -1,6 +1,6 @@ //---------------------------------------------------------------------------------------- // -// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// This code was generated by https://github.com/specklesystems/ProxyGenerator. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.IOperatorTest.g.cs b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.IOperatorTest.g.cs index ed9af73..6424a32 100644 --- a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.IOperatorTest.g.cs +++ b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.IOperatorTest.g.cs @@ -1,6 +1,6 @@ //---------------------------------------------------------------------------------------- // -// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// This code was generated by https://github.com/specklesystems/ProxyGenerator. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.IPerson.g.cs b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.IPerson.g.cs index 4e0f095..b19d572 100644 --- a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.IPerson.g.cs +++ b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.IPerson.g.cs @@ -1,6 +1,6 @@ //---------------------------------------------------------------------------------------- // -// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// This code was generated by https://github.com/specklesystems/ProxyGenerator. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.IPersonExtends.g.cs b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.IPersonExtends.g.cs index 8941e70..0ed6b87 100644 --- a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.IPersonExtends.g.cs +++ b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.IPersonExtends.g.cs @@ -1,6 +1,6 @@ //---------------------------------------------------------------------------------------- // -// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// This code was generated by https://github.com/specklesystems/ProxyGenerator. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.ITestClassInternal.g.cs b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.ITestClassInternal.g.cs index 55bb91c..021fe70 100644 --- a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.ITestClassInternal.g.cs +++ b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.ITestClassInternal.g.cs @@ -1,6 +1,6 @@ //---------------------------------------------------------------------------------------- // -// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// This code was generated by https://github.com/specklesystems/ProxyGenerator. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.IÜberGeneric.g.cs b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.IÜberGeneric.g.cs index 0aa50e1..c26cbcf 100644 --- a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.IÜberGeneric.g.cs +++ b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.IÜberGeneric.g.cs @@ -1,6 +1,6 @@ //---------------------------------------------------------------------------------------- // -// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// This code was generated by https://github.com/specklesystems/ProxyGenerator. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.MixedVisibilityProxy.g.cs b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.MixedVisibilityProxy.g.cs index a77f05a..106dc8d 100644 --- a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.MixedVisibilityProxy.g.cs +++ b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.MixedVisibilityProxy.g.cs @@ -1,6 +1,6 @@ //---------------------------------------------------------------------------------------- // -// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// This code was generated by https://github.com/specklesystems/ProxyGenerator. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.OperatorTestProxy.g.cs b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.OperatorTestProxy.g.cs index c2f4d00..fd9c206 100644 --- a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.OperatorTestProxy.g.cs +++ b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.OperatorTestProxy.g.cs @@ -1,6 +1,6 @@ //---------------------------------------------------------------------------------------- // -// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// This code was generated by https://github.com/specklesystems/ProxyGenerator. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.PersonExtendsProxy.g.cs b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.PersonExtendsProxy.g.cs index 9596d9b..0c5bbae 100644 --- a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.PersonExtendsProxy.g.cs +++ b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.PersonExtendsProxy.g.cs @@ -1,6 +1,6 @@ //---------------------------------------------------------------------------------------- // -// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// This code was generated by https://github.com/specklesystems/ProxyGenerator. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.PersonProxy.g.cs b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.PersonProxy.g.cs index 74403f4..5c321a4 100644 --- a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.PersonProxy.g.cs +++ b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.PersonProxy.g.cs @@ -1,6 +1,6 @@ //---------------------------------------------------------------------------------------- // -// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// This code was generated by https://github.com/specklesystems/ProxyGenerator. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientContext.g.cs b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientContext.g.cs index a4aabf0..c1b1bf5 100644 --- a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientContext.g.cs +++ b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientContext.g.cs @@ -1,6 +1,6 @@ //---------------------------------------------------------------------------------------- // -// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// This code was generated by https://github.com/specklesystems/ProxyGenerator. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientObject.g.cs b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientObject.g.cs index 8e04206..2412275 100644 --- a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientObject.g.cs +++ b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientObject.g.cs @@ -1,6 +1,6 @@ //---------------------------------------------------------------------------------------- // -// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// This code was generated by https://github.com/specklesystems/ProxyGenerator. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -12,7 +12,7 @@ using System; namespace ProxyInterfaceSourceGeneratorTests.Source.PnP { - public partial interface IClientObject : global::Microsoft.SharePoint.Client.IFromJson + public partial interface IClientObject { global::Microsoft.SharePoint.Client.ClientObject _Instance { get; } @@ -31,6 +31,12 @@ namespace ProxyInterfaceSourceGeneratorTests.Source.PnP global::ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientObject TypedObject { get; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + void FromJson(global::Microsoft.SharePoint.Client.JsonReader reader); + + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + bool CustomFromJson(global::Microsoft.SharePoint.Client.JsonReader reader); + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] void Retrieve(); diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientRuntimeContext.g.cs b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientRuntimeContext.g.cs index a2e828e..4a9079b 100644 --- a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientRuntimeContext.g.cs +++ b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientRuntimeContext.g.cs @@ -1,6 +1,6 @@ //---------------------------------------------------------------------------------------- // -// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// This code was generated by https://github.com/specklesystems/ProxyGenerator. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -12,7 +12,7 @@ using System; namespace ProxyInterfaceSourceGeneratorTests.Source.PnP { - public partial interface IClientRuntimeContext : global::System.IDisposable + public partial interface IClientRuntimeContext { global::Microsoft.SharePoint.Client.ClientRuntimeContext _Instance { get; } @@ -76,6 +76,8 @@ namespace ProxyInterfaceSourceGeneratorTests.Source.PnP global::System.Collections.Generic.IEnumerable LoadQuery(global::Microsoft.SharePoint.Client.ClientObjectCollection clientObjects) where T : Microsoft.SharePoint.Client.ClientObject; global::System.Collections.Generic.IEnumerable LoadQuery(global::System.Linq.IQueryable clientObjects) where T : Microsoft.SharePoint.Client.ClientObject; + + void Dispose(); } } #nullable restore \ No newline at end of file diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.PnP.ISecurableObject.g.cs b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.PnP.ISecurableObject.g.cs index fc11b64..11afdfb 100644 --- a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.PnP.ISecurableObject.g.cs +++ b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.PnP.ISecurableObject.g.cs @@ -1,6 +1,6 @@ //---------------------------------------------------------------------------------------- // -// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// This code was generated by https://github.com/specklesystems/ProxyGenerator. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -12,7 +12,7 @@ using System; namespace ProxyInterfaceSourceGeneratorTests.Source.PnP { - public partial interface ISecurableObject + public partial interface ISecurableObject : global::ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientObject { new global::Microsoft.SharePoint.Client.SecurableObject _Instance { get; } diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.PnP.IWeb.g.cs b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.PnP.IWeb.g.cs index d393967..dc047c7 100644 --- a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.PnP.IWeb.g.cs +++ b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.PnP.IWeb.g.cs @@ -1,6 +1,6 @@ //---------------------------------------------------------------------------------------- // -// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// This code was generated by https://github.com/specklesystems/ProxyGenerator. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -12,7 +12,7 @@ using System; namespace ProxyInterfaceSourceGeneratorTests.Source.PnP { - public partial interface IWeb + public partial interface IWeb : global::ProxyInterfaceSourceGeneratorTests.Source.PnP.ISecurableObject { new global::Microsoft.SharePoint.Client.Web _Instance { get; } diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.TestClassInternalProxy.g.cs b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.TestClassInternalProxy.g.cs index b39e393..6c323b3 100644 --- a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.TestClassInternalProxy.g.cs +++ b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.TestClassInternalProxy.g.cs @@ -1,6 +1,6 @@ //---------------------------------------------------------------------------------------- // -// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// This code was generated by https://github.com/specklesystems/ProxyGenerator. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.ÜberGeneric`3Proxy.g.cs b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.ÜberGeneric`3Proxy.g.cs index 3f6ecbc..4793470 100644 --- a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.ÜberGeneric`3Proxy.g.cs +++ b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.ÜberGeneric`3Proxy.g.cs @@ -1,6 +1,6 @@ //---------------------------------------------------------------------------------------- // -// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// This code was generated by https://github.com/specklesystems/ProxyGenerator. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Destination/System.Net.Http.HttpClientProxy.g.cs b/tests/ProxyInterfaceSourceGeneratorTests/Destination/System.Net.Http.HttpClientProxy.g.cs index 37ca3af..cd4066e 100644 --- a/tests/ProxyInterfaceSourceGeneratorTests/Destination/System.Net.Http.HttpClientProxy.g.cs +++ b/tests/ProxyInterfaceSourceGeneratorTests/Destination/System.Net.Http.HttpClientProxy.g.cs @@ -1,6 +1,6 @@ //---------------------------------------------------------------------------------------- // -// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// This code was generated by https://github.com/specklesystems/ProxyGenerator. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Destination/System.Net.Http.HttpMessageInvokerProxy.g.cs b/tests/ProxyInterfaceSourceGeneratorTests/Destination/System.Net.Http.HttpMessageInvokerProxy.g.cs index 01d18fe..6cac66f 100644 --- a/tests/ProxyInterfaceSourceGeneratorTests/Destination/System.Net.Http.HttpMessageInvokerProxy.g.cs +++ b/tests/ProxyInterfaceSourceGeneratorTests/Destination/System.Net.Http.HttpMessageInvokerProxy.g.cs @@ -1,6 +1,6 @@ //---------------------------------------------------------------------------------------- // -// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// This code was generated by https://github.com/specklesystems/ProxyGenerator. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/ProxyInterfaceSourceGeneratorTests/InheritedInterfaceTests.cs b/tests/ProxyInterfaceSourceGeneratorTests/InheritedInterfaceTests.cs index e9c19b9..74864ed 100644 --- a/tests/ProxyInterfaceSourceGeneratorTests/InheritedInterfaceTests.cs +++ b/tests/ProxyInterfaceSourceGeneratorTests/InheritedInterfaceTests.cs @@ -1,14 +1,24 @@ using CSharp.SourceGenerators.Extensions; using CSharp.SourceGenerators.Extensions.Models; using FluentAssertions; -using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Syntax; using ProxyInterfaceSourceGeneratorTests.Source.Disposable; using Speckle.ProxyGenerator; -using Xunit.Abstractions; namespace ProxyInterfaceSourceGeneratorTests; +[Flags] +public enum ImplementationOptions +{ + None = 0, + ProxyBaseClasses = 1, + + ProxyInterfaces = 2, + + UseExtendedInterfaces = 4, + + ProxyForBaseInterface = 8 +} public class InheritedInterfaceTests { private const string Namespace = "ProxyInterfaceSourceGeneratorTests.Source.Disposable"; @@ -25,10 +35,10 @@ public class InheritedInterfaceTests } [Theory] - [InlineData(false, false)] - [InlineData(true, true)] + [InlineData(ImplementationOptions.None, false)] + [InlineData(ImplementationOptions.ProxyBaseClasses | ImplementationOptions.ProxyInterfaces, true)] public void GenerateFiles_InheritedInterface_InheritFromBaseClass( - bool proxyBaseClass, + ImplementationOptions options, bool inheritBaseInterface ) { @@ -39,7 +49,7 @@ public class InheritedInterfaceTests // Arrange string[] fileNames = [$"{Namespace}.{interfaceName}.g.cs", $"{Namespace}.{proxyName}.g.cs"]; var path = $"./Source/Disposable/{interfaceName}.cs"; - SourceFile sourceFile = CreateSourceFile(path, name, proxyBaseClass); + SourceFile sourceFile = CreateSourceFile(path, name,options); // Act var result = _sut.Execute([sourceFile]); @@ -72,7 +82,7 @@ public class InheritedInterfaceTests string[] fileNames = [$"{Namespace}.{interfaceName}.g.cs", $"{Namespace}.{proxyName}.g.cs"]; var path = $"./Source/Disposable/{interfaceName}.cs"; - SourceFile sourceFile = CreateSourceFile(path, name, true); + SourceFile sourceFile = CreateSourceFile(path, name, ImplementationOptions.ProxyInterfaces | ImplementationOptions.ProxyBaseClasses | ImplementationOptions.UseExtendedInterfaces); // Act var result = _sut.Execute([sourceFile]); @@ -88,9 +98,9 @@ public class InheritedInterfaceTests // Assert Assert.Single(interfaceDeclarations); - var baseList = interfaceDeclarations.First().BaseList!; - Assert.Equal(2, baseList.Types.Count); - var type1 = (QualifiedNameSyntax)baseList.Types[0].Type; + var baseList = interfaceDeclarations.First().BaseList; + Assert.Equal(2, baseList?.Types.Count); + var type1 = (QualifiedNameSyntax)baseList!.Types[0].Type; var type2 = (QualifiedNameSyntax)baseList.Types[1].Type; Assert.Equal(nameof(IDisposable), type1.Right.Identifier.Text); Assert.Equal(nameof(IUpdate), type2.Right.Identifier.Text); @@ -107,7 +117,7 @@ public class InheritedInterfaceTests string[] fileNames = [$"{Namespace}.{interfaceName}.g.cs", $"{Namespace}.{proxyName}.g.cs"]; var interfaceIndex = 1; var path = $"./Source/Disposable/{interfaceName}.cs"; - SourceFile sourceFile = CreateSourceFile(path, name, true); + SourceFile sourceFile = CreateSourceFile(path, name, ImplementationOptions.UseExtendedInterfaces); // Act var result = _sut.Execute([sourceFile]); @@ -130,9 +140,26 @@ public class InheritedInterfaceTests Assert.True(noInterfaceImplementationFound); } - private static SourceFile CreateSourceFile(string path, string name, bool extend) + private static SourceFile CreateSourceFile(string path, string name, ImplementationOptions options) { - var extendString = extend.ToString().ToLowerInvariant(); + var o = string.Empty; + foreach (var val in Enum.GetValues()) + { + if (!options.HasFlag(val)) + { + continue; + } + if (o.Length > 0) + { + o += " | "; + } + + o += "ImplementationOptions." + val.ToString(); + } + if (o.Length == 0) + { + o = "ImplementationOptions.None"; + } return new SourceFile { Path = path, @@ -140,7 +167,7 @@ public class InheritedInterfaceTests AttributeToAddToInterface = new ExtraAttribute { Name = "Speckle.ProxyGenerator.Proxy", - ArgumentList = $"typeof({Namespace}.{name}), {extendString}" + ArgumentList = $"typeof({Namespace}.{name}), {o}" } }; } diff --git a/tests/ProxyInterfaceSourceGeneratorTests/PnPTests.cs b/tests/ProxyInterfaceSourceGeneratorTests/PnPTests.cs index cdcef4f..4b3b555 100644 --- a/tests/ProxyInterfaceSourceGeneratorTests/PnPTests.cs +++ b/tests/ProxyInterfaceSourceGeneratorTests/PnPTests.cs @@ -45,7 +45,7 @@ public class PnPTests AttributeToAddToInterface = new ExtraAttribute { Name = "Speckle.ProxyGenerator.Proxy", - ArgumentList = "typeof(Microsoft.SharePoint.Client.ClientObject)" + ArgumentList = new [] { "typeof(Microsoft.SharePoint.Client.ClientObject)", "ImplementationOptions.UseExtendedInterfaces"} } }; @@ -57,7 +57,7 @@ public class PnPTests AttributeToAddToInterface = new ExtraAttribute { Name = "Speckle.ProxyGenerator.Proxy", - ArgumentList = "typeof(SecurableObject)" // Only name, no namespace + ArgumentList =new [] { "typeof(SecurableObject)" , "ImplementationOptions.UseExtendedInterfaces"}// Only name, no namespace } }; @@ -69,7 +69,7 @@ public class PnPTests AttributeToAddToInterface = new ExtraAttribute { Name = "Speckle.ProxyGenerator.Proxy", - ArgumentList = "typeof(Web)" // Only name, no namespace + ArgumentList = new [] { "typeof(Web)", "ImplementationOptions.UseExtendedInterfaces"} // Only name, no namespace } }; @@ -81,7 +81,7 @@ public class PnPTests AttributeToAddToInterface = new ExtraAttribute { Name = "Speckle.ProxyGenerator.Proxy", - ArgumentList = "typeof(Microsoft.SharePoint.Client.ClientRuntimeContext)" + ArgumentList = new [] { "typeof(Microsoft.SharePoint.Client.ClientRuntimeContext)", "ImplementationOptions.UseExtendedInterfaces"} } }; @@ -93,7 +93,7 @@ public class PnPTests AttributeToAddToInterface = new ExtraAttribute { Name = "Speckle.ProxyGenerator.Proxy", - ArgumentList = "typeof(ClientContext)" // Only name, no namespace + ArgumentList =new [] { "typeof(Microsoft.SharePoint.Client.ClientContext)", "ImplementationOptions.UseExtendedInterfaces"} // Only name, no namespace } }; diff --git a/tests/ProxyInterfaceSourceGeneratorTests/ProxyInterfaceSourceGeneratorTest.GenerateFiles_ForClassWithArray_Should_GenerateCorrectFiles.verified.txt b/tests/ProxyInterfaceSourceGeneratorTests/ProxyInterfaceSourceGeneratorTest.GenerateFiles_ForClassWithArray_Should_GenerateCorrectFiles.verified.txt index 2ed5369..c02c2f4 100644 --- a/tests/ProxyInterfaceSourceGeneratorTests/ProxyInterfaceSourceGeneratorTest.GenerateFiles_ForClassWithArray_Should_GenerateCorrectFiles.verified.txt +++ b/tests/ProxyInterfaceSourceGeneratorTests/ProxyInterfaceSourceGeneratorTest.GenerateFiles_ForClassWithArray_Should_GenerateCorrectFiles.verified.txt @@ -11,6 +11,7 @@ // //---------------------------------------------------------------------------------------- +#nullable enable using System; namespace Speckle.ProxyGenerator @@ -19,34 +20,38 @@ namespace Speckle.ProxyGenerator internal sealed class ProxyAttribute : Attribute { public Type Type { get; } - public bool ProxyBaseClasses { get; } + public ImplementationOptions Options { get; } public ProxyClassAccessibility Accessibility { get; } public string[]? MembersToIgnore { get; } - public ProxyAttribute(Type type) : this(type, false, ProxyClassAccessibility.Public) + public ProxyAttribute(Type type) : this(type, ImplementationOptions.None, ProxyClassAccessibility.Public) { } - public ProxyAttribute(Type type, bool proxyBaseClasses) : this(type, proxyBaseClasses, ProxyClassAccessibility.Public) + public ProxyAttribute(Type type, ImplementationOptions options) : this(type, options, ProxyClassAccessibility.Public) { } - public ProxyAttribute(Type type, ProxyClassAccessibility accessibility) : this(type, false, accessibility) + public ProxyAttribute(Type type, ProxyClassAccessibility accessibility) : this(type, ImplementationOptions.None, accessibility) { } - public ProxyAttribute(Type type, bool proxyBaseClasses, ProxyClassAccessibility accessibility) : this(type, proxyBaseClasses, accessibility, null) + public ProxyAttribute(Type type, ImplementationOptions options, ProxyClassAccessibility accessibility) : this(type, options, accessibility, null) { } - public ProxyAttribute(Type type, string[]? membersToIgnore) : this(type, false, ProxyClassAccessibility.Public, null) + public ProxyAttribute(Type type, string[]? membersToIgnore) : this(type, ImplementationOptions.None, ProxyClassAccessibility.Public, null) { } - public ProxyAttribute(Type type, bool proxyBaseClasses, ProxyClassAccessibility accessibility, string[]? membersToIgnore) + public ProxyAttribute(Type type, ImplementationOptions options, string[]? membersToIgnore) : this(type, options, ProxyClassAccessibility.Public, null) + { + } + + public ProxyAttribute(Type type, ImplementationOptions options, ProxyClassAccessibility accessibility, string[]? membersToIgnore) { Type = type; - ProxyBaseClasses = proxyBaseClasses; + Options = options; Accessibility = accessibility; MembersToIgnore = membersToIgnore; } @@ -59,6 +64,20 @@ namespace Speckle.ProxyGenerator Internal = 1 } + [Flags] + internal enum ImplementationOptions + { + None = 0, + + ProxyBaseClasses = 1, + + ProxyInterfaces = 2, + + UseExtendedInterfaces = 4, + + ProxyForBaseInterface = 8 + } +#nullable restore } }, { @@ -66,7 +85,7 @@ namespace Speckle.ProxyGenerator Source: //---------------------------------------------------------------------------------------- // -// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// This code was generated by https://github.com/specklesystems/ProxyGenerator. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -94,7 +113,7 @@ namespace ProxyInterfaceSourceGeneratorTests.Source Source: //---------------------------------------------------------------------------------------- // -// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// This code was generated by https://github.com/specklesystems/ProxyGenerator. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/ProxyInterfaceSourceGeneratorTests/ProxyInterfaceSourceGeneratorTest.GenerateFiles_ForClassWithIgnores.verified.txt b/tests/ProxyInterfaceSourceGeneratorTests/ProxyInterfaceSourceGeneratorTest.GenerateFiles_ForClassWithIgnores.verified.txt index c330b9c..cc514aa 100644 --- a/tests/ProxyInterfaceSourceGeneratorTests/ProxyInterfaceSourceGeneratorTest.GenerateFiles_ForClassWithIgnores.verified.txt +++ b/tests/ProxyInterfaceSourceGeneratorTests/ProxyInterfaceSourceGeneratorTest.GenerateFiles_ForClassWithIgnores.verified.txt @@ -11,6 +11,7 @@ // //---------------------------------------------------------------------------------------- +#nullable enable using System; namespace Speckle.ProxyGenerator @@ -19,34 +20,38 @@ namespace Speckle.ProxyGenerator internal sealed class ProxyAttribute : Attribute { public Type Type { get; } - public bool ProxyBaseClasses { get; } + public ImplementationOptions Options { get; } public ProxyClassAccessibility Accessibility { get; } public string[]? MembersToIgnore { get; } - public ProxyAttribute(Type type) : this(type, false, ProxyClassAccessibility.Public) + public ProxyAttribute(Type type) : this(type, ImplementationOptions.None, ProxyClassAccessibility.Public) { } - public ProxyAttribute(Type type, bool proxyBaseClasses) : this(type, proxyBaseClasses, ProxyClassAccessibility.Public) + public ProxyAttribute(Type type, ImplementationOptions options) : this(type, options, ProxyClassAccessibility.Public) { } - public ProxyAttribute(Type type, ProxyClassAccessibility accessibility) : this(type, false, accessibility) + public ProxyAttribute(Type type, ProxyClassAccessibility accessibility) : this(type, ImplementationOptions.None, accessibility) { } - public ProxyAttribute(Type type, bool proxyBaseClasses, ProxyClassAccessibility accessibility) : this(type, proxyBaseClasses, accessibility, null) + public ProxyAttribute(Type type, ImplementationOptions options, ProxyClassAccessibility accessibility) : this(type, options, accessibility, null) { } - public ProxyAttribute(Type type, string[]? membersToIgnore) : this(type, false, ProxyClassAccessibility.Public, null) + public ProxyAttribute(Type type, string[]? membersToIgnore) : this(type, ImplementationOptions.None, ProxyClassAccessibility.Public, null) { } - public ProxyAttribute(Type type, bool proxyBaseClasses, ProxyClassAccessibility accessibility, string[]? membersToIgnore) + public ProxyAttribute(Type type, ImplementationOptions options, string[]? membersToIgnore) : this(type, options, ProxyClassAccessibility.Public, null) + { + } + + public ProxyAttribute(Type type, ImplementationOptions options, ProxyClassAccessibility accessibility, string[]? membersToIgnore) { Type = type; - ProxyBaseClasses = proxyBaseClasses; + Options = options; Accessibility = accessibility; MembersToIgnore = membersToIgnore; } @@ -59,6 +64,20 @@ namespace Speckle.ProxyGenerator Internal = 1 } + [Flags] + internal enum ImplementationOptions + { + None = 0, + + ProxyBaseClasses = 1, + + ProxyInterfaces = 2, + + UseExtendedInterfaces = 4, + + ProxyForBaseInterface = 8 + } +#nullable restore } }, { @@ -66,7 +85,7 @@ namespace Speckle.ProxyGenerator Source: //---------------------------------------------------------------------------------------- // -// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// This code was generated by https://github.com/specklesystems/ProxyGenerator. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -96,7 +115,7 @@ namespace ProxyInterfaceSourceGeneratorTests.Source Source: //---------------------------------------------------------------------------------------- // -// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// This code was generated by https://github.com/specklesystems/ProxyGenerator. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tests/ProxyInterfaceSourceGeneratorTests/ProxyInterfaceSourceGeneratorTest.GenerateFiles_ForClassWith_BaseInterface.verified.txt b/tests/ProxyInterfaceSourceGeneratorTests/ProxyInterfaceSourceGeneratorTest.GenerateFiles_ForClassWith_BaseInterface.verified.txt new file mode 100644 index 0000000..8c30f36 --- /dev/null +++ b/tests/ProxyInterfaceSourceGeneratorTests/ProxyInterfaceSourceGeneratorTest.GenerateFiles_ForClassWith_BaseInterface.verified.txt @@ -0,0 +1,165 @@ +[ + { + HintName: Speckle.ProxyGenerator.Extra.g.cs, + Source: +//---------------------------------------------------------------------------------------- +// +// This code was generated by https://github.com/specklesystems/ProxyGenerator +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//---------------------------------------------------------------------------------------- + +#nullable enable +using System; + +namespace Speckle.ProxyGenerator +{ + [AttributeUsage(AttributeTargets.Interface)] + internal sealed class ProxyAttribute : Attribute + { + public Type Type { get; } + public ImplementationOptions Options { get; } + public ProxyClassAccessibility Accessibility { get; } + public string[]? MembersToIgnore { get; } + + public ProxyAttribute(Type type) : this(type, ImplementationOptions.None, ProxyClassAccessibility.Public) + { + } + + public ProxyAttribute(Type type, ImplementationOptions options) : this(type, options, ProxyClassAccessibility.Public) + { + } + + public ProxyAttribute(Type type, ProxyClassAccessibility accessibility) : this(type, ImplementationOptions.None, accessibility) + { + } + + public ProxyAttribute(Type type, ImplementationOptions options, ProxyClassAccessibility accessibility) : this(type, options, accessibility, null) + { + } + + public ProxyAttribute(Type type, string[]? membersToIgnore) : this(type, ImplementationOptions.None, ProxyClassAccessibility.Public, null) + { + } + + public ProxyAttribute(Type type, ImplementationOptions options, string[]? membersToIgnore) : this(type, options, ProxyClassAccessibility.Public, null) + { + } + + public ProxyAttribute(Type type, ImplementationOptions options, ProxyClassAccessibility accessibility, string[]? membersToIgnore) + { + Type = type; + Options = options; + Accessibility = accessibility; + MembersToIgnore = membersToIgnore; + } + } + + [Flags] + internal enum ProxyClassAccessibility + { + Public = 0, + + Internal = 1 + } + [Flags] + internal enum ImplementationOptions + { + None = 0, + + ProxyBaseClasses = 1, + + ProxyInterfaces = 2, + + UseExtendedInterfaces = 4, + + ProxyForBaseInterface = 8 + } +#nullable restore +} + }, + { + HintName: ProxyInterfaceSourceGeneratorTests.Source.IFoo2.g.cs, + Source: +//---------------------------------------------------------------------------------------- +// +// This code was generated by https://github.com/specklesystems/ProxyGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//---------------------------------------------------------------------------------------- + +#nullable enable +using System; + +namespace ProxyInterfaceSourceGeneratorTests.Source +{ + public partial interface IFoo2 : global::ProxyInterfaceSourceGeneratorTests.Source.IFoo2Base + { + global::ProxyInterfaceSourceGeneratorTests.Source.Foo2 _Instance { get; } + + global::ProxyInterfaceSourceGeneratorTests.Source.IFoo2[] Foos { get; set; } + + int Weird { get; set; } + + global::ProxyInterfaceSourceGeneratorTests.Source.IFoo2[] DoSomethingAndGetAnArrayOfFoos(); + } +} +#nullable restore + }, + { + HintName: ProxyInterfaceSourceGeneratorTests.Source.Foo2Proxy.g.cs, + Source: +//---------------------------------------------------------------------------------------- +// +// This code was generated by https://github.com/specklesystems/ProxyGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//---------------------------------------------------------------------------------------- + +#nullable enable +using System; + +namespace ProxyInterfaceSourceGeneratorTests.Source +{ + public partial class Foo2Proxy : global::ProxyInterfaceSourceGeneratorTests.Source.IFoo2 + { + public global::ProxyInterfaceSourceGeneratorTests.Source.Foo2 _Instance { get; } + + public global::ProxyInterfaceSourceGeneratorTests.Source.IFoo2[] Foos { get => Mapster.TypeAdapter.Adapt(_Instance.Foos); set => _Instance.Foos = Mapster.TypeAdapter.Adapt(value); } + + public int Weird { get => _Instance.Weird; set => _Instance.Weird = value; } + + public global::ProxyInterfaceSourceGeneratorTests.Source.IFoo2[] DoSomethingAndGetAnArrayOfFoos() + { + var result_1603865878 = _Instance.DoSomethingAndGetAnArrayOfFoos(); + return Mapster.TypeAdapter.Adapt(result_1603865878); + } + + public int Weird2() + { + var result__1602200929 = _Instance.Weird2(); + return result__1602200929; + } + + + public Foo2Proxy(global::ProxyInterfaceSourceGeneratorTests.Source.Foo2 instance) + { + _Instance = instance; + + + Mapster.TypeAdapterConfig.NewConfig().ConstructUsing(instance1325374861 => new global::ProxyInterfaceSourceGeneratorTests.Source.Foo2Proxy(instance1325374861)); + Mapster.TypeAdapterConfig.NewConfig().MapWith(proxy1047178445 => ((global::ProxyInterfaceSourceGeneratorTests.Source.Foo2Proxy) proxy1047178445)._Instance); + + + } + } +} +#nullable restore + } +] \ No newline at end of file diff --git a/tests/ProxyInterfaceSourceGeneratorTests/ProxyInterfaceSourceGeneratorTest.GenerateFiles_ForClassWith_Extended.verified.txt b/tests/ProxyInterfaceSourceGeneratorTests/ProxyInterfaceSourceGeneratorTest.GenerateFiles_ForClassWith_Extended.verified.txt new file mode 100644 index 0000000..a9e0fce --- /dev/null +++ b/tests/ProxyInterfaceSourceGeneratorTests/ProxyInterfaceSourceGeneratorTest.GenerateFiles_ForClassWith_Extended.verified.txt @@ -0,0 +1,213 @@ +[ + { + HintName: Speckle.ProxyGenerator.Extra.g.cs, + Source: +//---------------------------------------------------------------------------------------- +// +// This code was generated by https://github.com/specklesystems/ProxyGenerator +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//---------------------------------------------------------------------------------------- + +#nullable enable +using System; + +namespace Speckle.ProxyGenerator +{ + [AttributeUsage(AttributeTargets.Interface)] + internal sealed class ProxyAttribute : Attribute + { + public Type Type { get; } + public ImplementationOptions Options { get; } + public ProxyClassAccessibility Accessibility { get; } + public string[]? MembersToIgnore { get; } + + public ProxyAttribute(Type type) : this(type, ImplementationOptions.None, ProxyClassAccessibility.Public) + { + } + + public ProxyAttribute(Type type, ImplementationOptions options) : this(type, options, ProxyClassAccessibility.Public) + { + } + + public ProxyAttribute(Type type, ProxyClassAccessibility accessibility) : this(type, ImplementationOptions.None, accessibility) + { + } + + public ProxyAttribute(Type type, ImplementationOptions options, ProxyClassAccessibility accessibility) : this(type, options, accessibility, null) + { + } + + public ProxyAttribute(Type type, string[]? membersToIgnore) : this(type, ImplementationOptions.None, ProxyClassAccessibility.Public, null) + { + } + + public ProxyAttribute(Type type, ImplementationOptions options, string[]? membersToIgnore) : this(type, options, ProxyClassAccessibility.Public, null) + { + } + + public ProxyAttribute(Type type, ImplementationOptions options, ProxyClassAccessibility accessibility, string[]? membersToIgnore) + { + Type = type; + Options = options; + Accessibility = accessibility; + MembersToIgnore = membersToIgnore; + } + } + + [Flags] + internal enum ProxyClassAccessibility + { + Public = 0, + + Internal = 1 + } + [Flags] + internal enum ImplementationOptions + { + None = 0, + + ProxyBaseClasses = 1, + + ProxyInterfaces = 2, + + UseExtendedInterfaces = 4, + + ProxyForBaseInterface = 8 + } +#nullable restore +} + }, + { + HintName: ProxyInterfaceSourceGeneratorTests.Source.IFoo3Proxy.g.cs, + Source: +//---------------------------------------------------------------------------------------- +// +// This code was generated by https://github.com/specklesystems/ProxyGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//---------------------------------------------------------------------------------------- + +#nullable enable +using System; + +namespace ProxyInterfaceSourceGeneratorTests.Source +{ + public partial interface IFoo3Proxy : global::ProxyInterfaceSourceGeneratorTests.Source.IFoo3 + { + global::ProxyInterfaceSourceGeneratorTests.Source.Foo3 _Instance { get; } + + + } +} +#nullable restore + }, + { + HintName: ProxyInterfaceSourceGeneratorTests.Source.IBar3Proxy.g.cs, + Source: +//---------------------------------------------------------------------------------------- +// +// This code was generated by https://github.com/specklesystems/ProxyGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//---------------------------------------------------------------------------------------- + +#nullable enable +using System; + +namespace ProxyInterfaceSourceGeneratorTests.Source +{ + public partial interface IBar3Proxy : global::ProxyInterfaceSourceGeneratorTests.Source.IBar3 + { + global::ProxyInterfaceSourceGeneratorTests.Source.Bar3 _Instance { get; } + + + } +} +#nullable restore + }, + { + HintName: ProxyInterfaceSourceGeneratorTests.Source.Foo3Proxy.g.cs, + Source: +//---------------------------------------------------------------------------------------- +// +// This code was generated by https://github.com/specklesystems/ProxyGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//---------------------------------------------------------------------------------------- + +#nullable enable +using System; + +namespace ProxyInterfaceSourceGeneratorTests.Source +{ + public partial class Foo3Proxy : global::ProxyInterfaceSourceGeneratorTests.Source.IFoo3 + { + public global::ProxyInterfaceSourceGeneratorTests.Source.Foo3 _Instance { get; } + + public global::ProxyInterfaceSourceGeneratorTests.Source.IBar3 Weird() + { + var result_867036441 = _Instance.Weird(); + return Mapster.TypeAdapter.Adapt(result_867036441); + } + + + public Foo3Proxy(global::ProxyInterfaceSourceGeneratorTests.Source.Foo3 instance) + { + _Instance = instance; + + + Mapster.TypeAdapterConfig.NewConfig().ConstructUsing(instance969373361 => new global::ProxyInterfaceSourceGeneratorTests.Source.Bar3Proxy(instance969373361)); + Mapster.TypeAdapterConfig.NewConfig().MapWith(proxy339001485 => ((global::ProxyInterfaceSourceGeneratorTests.Source.Bar3Proxy) proxy339001485)._Instance); + + + } + } +} +#nullable restore + }, + { + HintName: ProxyInterfaceSourceGeneratorTests.Source.Bar3Proxy.g.cs, + Source: +//---------------------------------------------------------------------------------------- +// +// This code was generated by https://github.com/specklesystems/ProxyGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//---------------------------------------------------------------------------------------- + +#nullable enable +using System; + +namespace ProxyInterfaceSourceGeneratorTests.Source +{ + public partial class Bar3Proxy : global::ProxyInterfaceSourceGeneratorTests.Source.IBar3 + { + public global::ProxyInterfaceSourceGeneratorTests.Source.Bar3 _Instance { get; } + + + public Bar3Proxy(global::ProxyInterfaceSourceGeneratorTests.Source.Bar3 instance) + { + _Instance = instance; + + + Mapster.TypeAdapterConfig.NewConfig().ConstructUsing(instance969373361 => new global::ProxyInterfaceSourceGeneratorTests.Source.Bar3Proxy(instance969373361)); + Mapster.TypeAdapterConfig.NewConfig().MapWith(proxy339001485 => ((global::ProxyInterfaceSourceGeneratorTests.Source.Bar3Proxy) proxy339001485)._Instance); + + + } + } +} +#nullable restore + } +] \ No newline at end of file diff --git a/tests/ProxyInterfaceSourceGeneratorTests/ProxyInterfaceSourceGeneratorTest.cs b/tests/ProxyInterfaceSourceGeneratorTests/ProxyInterfaceSourceGeneratorTest.cs index a9aed7c..ca18c74 100644 --- a/tests/ProxyInterfaceSourceGeneratorTests/ProxyInterfaceSourceGeneratorTest.cs +++ b/tests/ProxyInterfaceSourceGeneratorTests/ProxyInterfaceSourceGeneratorTest.cs @@ -104,7 +104,7 @@ public class ProxyInterfaceSourceGeneratorTest ArgumentList = new[] { "typeof(ProxyInterfaceSourceGeneratorTests.Source.Foo2)", - "false", + "ImplementationOptions.None", "ProxyClassAccessibility.Public", "new []{\"Weird\",\"NotHere\"}" } @@ -123,6 +123,100 @@ public class ProxyInterfaceSourceGeneratorTest return Verify(results); } + + [Fact] + public Task GenerateFiles_ForClassWith_BaseInterface() + { + // Arrange + var fileNames = new[] + { + "ProxyInterfaceSourceGeneratorTests.Source.IFoo2.g.cs", + "ProxyInterfaceSourceGeneratorTests.Source.Foo2Proxy.g.cs" + }; + + var path = "./Source/IFoo2.cs"; + var sourceFile = new SourceFile + { + Path = path, + Text = File.ReadAllText(path), + AttributeToAddToInterface = new ExtraAttribute + { + Name = "Speckle.ProxyGenerator.Proxy", + ArgumentList = new[] + { + "typeof(ProxyInterfaceSourceGeneratorTests.Source.Foo2)", + "ImplementationOptions.UseExtendedInterfaces", "ProxyClassAccessibility.Public" + } + } + }; + // Act + var result = _sut.Execute(new[] { sourceFile }); + + // Assert + result.Valid.Should().BeTrue(); + result.Files.Should().HaveCount(fileNames.Length + 1); + + // Verify + var results = result.GeneratorDriver.GetRunResult().Results.First().GeneratedSources; + return Verify(results); + } + + [Fact] + public Task GenerateFiles_ForClassWith_Extended() + { + // Arrange + var fileNames = new[] + { + "ProxyInterfaceSourceGeneratorTests.Source.IFoo3Proxy.g.cs", + "ProxyInterfaceSourceGeneratorTests.Source.Foo3Proxy.g.cs", + "ProxyInterfaceSourceGeneratorTests.Source.IBar3Proxy.g.cs", + "ProxyInterfaceSourceGeneratorTests.Source.Bar3Proxy.g.cs" + }; + + var path = "./Source/IFoo3Proxy.cs"; + var sourceFile = new SourceFile + { + Path = path, + Text = File.ReadAllText(path), + AttributeToAddToInterface = new ExtraAttribute + { + Name = "Speckle.ProxyGenerator.Proxy", + ArgumentList = new[] + { + "typeof(ProxyInterfaceSourceGeneratorTests.Source.Foo3)", + "ImplementationOptions.UseExtendedInterfaces | ImplementationOptions.ProxyForBaseInterface", + "ProxyClassAccessibility.Public" + } + } + }; + var path2 = "./Source/IBar3Proxy.cs"; + var sourceFile2 = new SourceFile + { + Path = path2, + Text = File.ReadAllText(path2), + AttributeToAddToInterface = new ExtraAttribute + { + Name = "Speckle.ProxyGenerator.Proxy", + ArgumentList = new[] + { + "typeof(ProxyInterfaceSourceGeneratorTests.Source.Bar3)", + "ImplementationOptions.UseExtendedInterfaces | ImplementationOptions.ProxyForBaseInterface", + "ProxyClassAccessibility.Public" + } + } + }; + // Act + var result = _sut.Execute(new[] { sourceFile, sourceFile2 }); + + // Assert + result.Valid.Should().BeTrue(); + result.Files.Should().HaveCount(fileNames.Length + 1); + + // Verify + var results = result.GeneratorDriver.GetRunResult().Results.First().GeneratedSources; + return Verify(results); + } + [Fact] public void GenerateFiles_ForGenericType_Should_GenerateCorrectFiles() { @@ -351,7 +445,7 @@ public class ProxyInterfaceSourceGeneratorTest ArgumentList = new[] { "typeof(ProxyInterfaceSourceGeneratorTests.Source.PersonExtends)", - "true" + "ImplementationOptions.ProxyBaseClasses" } } }; @@ -688,7 +782,7 @@ public class ProxyInterfaceSourceGeneratorTest ArgumentList = new[] { $"typeof(ProxyInterfaceSourceGeneratorTests.Namespace{x}.{@class})", - "true" + "ImplementationOptions.ProxyBaseClasses" } } }; diff --git a/tests/ProxyInterfaceSourceGeneratorTests/ProxyInterfaceSourceGeneratorTests.csproj b/tests/ProxyInterfaceSourceGeneratorTests/ProxyInterfaceSourceGeneratorTests.csproj index 9368a69..a1db8cf 100644 --- a/tests/ProxyInterfaceSourceGeneratorTests/ProxyInterfaceSourceGeneratorTests.csproj +++ b/tests/ProxyInterfaceSourceGeneratorTests/ProxyInterfaceSourceGeneratorTests.csproj @@ -11,7 +11,6 @@ - @@ -64,6 +63,12 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Source/Foo3.cs b/tests/ProxyInterfaceSourceGeneratorTests/Source/Foo3.cs new file mode 100644 index 0000000..72203fe --- /dev/null +++ b/tests/ProxyInterfaceSourceGeneratorTests/Source/Foo3.cs @@ -0,0 +1,15 @@ +using System.Diagnostics.CodeAnalysis; + +namespace ProxyInterfaceSourceGeneratorTests.Source; + +public class Foo3 +{ + public Bar3 Weird() + { + throw new NotImplementedException(); + } +} + +public class Bar3 +{ +} diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Source/IBar3.cs b/tests/ProxyInterfaceSourceGeneratorTests/Source/IBar3.cs new file mode 100644 index 0000000..ee9480c --- /dev/null +++ b/tests/ProxyInterfaceSourceGeneratorTests/Source/IBar3.cs @@ -0,0 +1,5 @@ +namespace ProxyInterfaceSourceGeneratorTests.Source; + +public partial interface IBar3 +{ +} diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Source/IBar3Proxy.cs b/tests/ProxyInterfaceSourceGeneratorTests/Source/IBar3Proxy.cs new file mode 100644 index 0000000..daeccf3 --- /dev/null +++ b/tests/ProxyInterfaceSourceGeneratorTests/Source/IBar3Proxy.cs @@ -0,0 +1,7 @@ +namespace ProxyInterfaceSourceGeneratorTests.Source; + + +public partial interface IBar3Proxy : IBar3 +{ + +} diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Source/IFoo2.cs b/tests/ProxyInterfaceSourceGeneratorTests/Source/IFoo2.cs index 551c60c..1035b82 100644 --- a/tests/ProxyInterfaceSourceGeneratorTests/Source/IFoo2.cs +++ b/tests/ProxyInterfaceSourceGeneratorTests/Source/IFoo2.cs @@ -1,4 +1,8 @@ namespace ProxyInterfaceSourceGeneratorTests.Source { - public partial interface IFoo2 { } + public partial interface IFoo2: IFoo2Base { } + public partial interface IFoo2Base + { + int Weird2(); + } } diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Source/IFoo3.cs b/tests/ProxyInterfaceSourceGeneratorTests/Source/IFoo3.cs new file mode 100644 index 0000000..d06556d --- /dev/null +++ b/tests/ProxyInterfaceSourceGeneratorTests/Source/IFoo3.cs @@ -0,0 +1,8 @@ +namespace ProxyInterfaceSourceGeneratorTests.Source +{ + public partial interface IFoo3 + { + IBar3 Weird(); + } + +} diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Source/IFoo3Proxy.cs b/tests/ProxyInterfaceSourceGeneratorTests/Source/IFoo3Proxy.cs new file mode 100644 index 0000000..060c0fd --- /dev/null +++ b/tests/ProxyInterfaceSourceGeneratorTests/Source/IFoo3Proxy.cs @@ -0,0 +1,3 @@ +namespace ProxyInterfaceSourceGeneratorTests.Source; + +public partial interface IFoo3Proxy: IFoo3 { }