From af99f41dc9259c67a57672a6f40a766d76c1c815 Mon Sep 17 00:00:00 2001 From: Stef Heyenrath Date: Sat, 25 Feb 2023 10:12:37 +0100 Subject: [PATCH] 0.0.34 --- Generate-ReleaseNotes.bat | 2 +- PackageReleaseNotes.txt | 2 +- ProxyInterfaceSourceGenerator Solution.sln | 17 +-- ReleaseNotes.md | 2 +- .../ProxyInterfaceConsumer/IPerson.cs | 4 +- .../ProxyInterfaceConsumerViaNuGet/IPerson.cs | 4 +- .../PersonProxy2.cs | 119 ------------------ .../ProxyInterfaceConsumerViaNuGet.csproj | 22 ++-- ...uteGenerator.cs => ExtraFilesGenerator.cs} | 118 ++++++++--------- .../ProxyInterfaceCodeGenerator.cs | 2 +- .../ProxyInterfaceSourceGenerator.csproj | 2 +- 11 files changed, 91 insertions(+), 203 deletions(-) delete mode 100644 src-examples/ProxyInterfaceConsumerViaNuGet/PersonProxy2.cs rename src/ProxyInterfaceSourceGenerator/FileGenerators/{ProxyAttributeGenerator.cs => ExtraFilesGenerator.cs} (55%) diff --git a/Generate-ReleaseNotes.bat b/Generate-ReleaseNotes.bat index 0d89bf0..6a6a496 100644 --- a/Generate-ReleaseNotes.bat +++ b/Generate-ReleaseNotes.bat @@ -1,6 +1,6 @@ rem https://github.com/StefH/GitHubReleaseNotes -SET version=0.0.33 +SET version=0.0.34 GitHubReleaseNotes --output "ReleaseNotes.md" --skip-empty-releases --exclude-labels question invalid doc --version %version% diff --git a/PackageReleaseNotes.txt b/PackageReleaseNotes.txt index 928ecfd..c047b5a 100644 --- a/PackageReleaseNotes.txt +++ b/PackageReleaseNotes.txt @@ -1,4 +1,4 @@ -# 0.0.33 (24 February 2023) +# 0.0.34 (25 February 2023) - #58 Add support for public and internal ProxyClass [enhancement] - #56 Internal proxies/Proxy factory [enhancement] diff --git a/ProxyInterfaceSourceGenerator Solution.sln b/ProxyInterfaceSourceGenerator Solution.sln index e59fa44..684e76f 100644 --- a/ProxyInterfaceSourceGenerator Solution.sln +++ b/ProxyInterfaceSourceGenerator Solution.sln @@ -24,14 +24,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProxyInterfaceSourceGenerat EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProxyInterfaceConsumer", "src-examples\ProxyInterfaceConsumer\ProxyInterfaceConsumer.csproj", "{7E0A10EE-CCC3-4281-9541-B0AF037D3DF9}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProxyInterfaceConsumerViaNuGet", "src-examples\ProxyInterfaceConsumerViaNuGet\ProxyInterfaceConsumerViaNuGet.csproj", "{6BEBFEB9-635F-44A2-949C-15DDDF0B7740}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProxyInterfaceSourceGeneratorTests", "tests\ProxyInterfaceSourceGeneratorTests\ProxyInterfaceSourceGeneratorTests.csproj", "{1BDB9046-D6D1-4FB4-AAB5-F24E33EEAE0A}" 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 GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -50,11 +50,6 @@ Global {7E0A10EE-CCC3-4281-9541-B0AF037D3DF9}.DebugAttach|Any CPU.ActiveCfg = Debug|Any CPU {7E0A10EE-CCC3-4281-9541-B0AF037D3DF9}.Release|Any CPU.ActiveCfg = Release|Any CPU {7E0A10EE-CCC3-4281-9541-B0AF037D3DF9}.Release|Any CPU.Build.0 = Release|Any CPU - {6BEBFEB9-635F-44A2-949C-15DDDF0B7740}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6BEBFEB9-635F-44A2-949C-15DDDF0B7740}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6BEBFEB9-635F-44A2-949C-15DDDF0B7740}.DebugAttach|Any CPU.ActiveCfg = Debug|Any CPU - {6BEBFEB9-635F-44A2-949C-15DDDF0B7740}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6BEBFEB9-635F-44A2-949C-15DDDF0B7740}.Release|Any CPU.Build.0 = Release|Any CPU {1BDB9046-D6D1-4FB4-AAB5-F24E33EEAE0A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1BDB9046-D6D1-4FB4-AAB5-F24E33EEAE0A}.Debug|Any CPU.Build.0 = Debug|Any CPU {1BDB9046-D6D1-4FB4-AAB5-F24E33EEAE0A}.DebugAttach|Any CPU.ActiveCfg = DebugAttach|Any CPU @@ -73,6 +68,12 @@ Global {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 + {1EA000E4-6103-4577-8D98-BDDA3BE458A2}.DebugAttach|Any CPU.Build.0 = Debug|Any CPU + {1EA000E4-6103-4577-8D98-BDDA3BE458A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1EA000E4-6103-4577-8D98-BDDA3BE458A2}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -80,10 +81,10 @@ Global GlobalSection(NestedProjects) = preSolution {12344228-91F4-4502-9595-39584E5ABB34} = {ED3DA9DD-1E07-444B-A2D7-2DBA280F96D4} {7E0A10EE-CCC3-4281-9541-B0AF037D3DF9} = {38BA087F-EDA1-4F8A-A140-85B84791B815} - {6BEBFEB9-635F-44A2-949C-15DDDF0B7740} = {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 SolutionGuid = {585F071D-051D-441C-9C6B-226D9E15A1F5} diff --git a/ReleaseNotes.md b/ReleaseNotes.md index 234d7dd..2b2b63d 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -1,4 +1,4 @@ -# 0.0.33 (24 February 2023) +# 0.0.34 (25 February 2023) - [#58](https://github.com/StefH/ProxyInterfaceSourceGenerator/pull/58) - Add support for public and internal ProxyClass [enhancement] contributed by [StefH](https://github.com/StefH) - [#56](https://github.com/StefH/ProxyInterfaceSourceGenerator/issues/56) - Internal proxies/Proxy factory [enhancement] diff --git a/src-examples/ProxyInterfaceConsumer/IPerson.cs b/src-examples/ProxyInterfaceConsumer/IPerson.cs index 7bf496d..156aaed 100644 --- a/src-examples/ProxyInterfaceConsumer/IPerson.cs +++ b/src-examples/ProxyInterfaceConsumer/IPerson.cs @@ -1,6 +1,8 @@ +using ProxyInterfaceGenerator; + namespace ProxyInterfaceConsumer { - [ProxyInterfaceGenerator.Proxy(typeof(ProxyInterfaceConsumer.Person))] + [Proxy(typeof(ProxyInterfaceConsumer.Person), ProxyClassAccessibility.Internal)] public partial interface IPerson { } diff --git a/src-examples/ProxyInterfaceConsumerViaNuGet/IPerson.cs b/src-examples/ProxyInterfaceConsumerViaNuGet/IPerson.cs index e565cb5..2969bc2 100644 --- a/src-examples/ProxyInterfaceConsumerViaNuGet/IPerson.cs +++ b/src-examples/ProxyInterfaceConsumerViaNuGet/IPerson.cs @@ -1,6 +1,6 @@ -namespace ProxyInterfaceConsumer +namespace ProxyInterfaceConsumer { - [ProxyInterfaceGenerator.Proxy(typeof(ProxyInterfaceConsumer.Person))] + [ProxyInterfaceGenerator.Proxy(typeof(ProxyInterfaceConsumer.Person), ProxyClassAccessibility.Internal))] public partial interface IPerson { } diff --git a/src-examples/ProxyInterfaceConsumerViaNuGet/PersonProxy2.cs b/src-examples/ProxyInterfaceConsumerViaNuGet/PersonProxy2.cs deleted file mode 100644 index d600ae6..0000000 --- a/src-examples/ProxyInterfaceConsumerViaNuGet/PersonProxy2.cs +++ /dev/null @@ -1,119 +0,0 @@ -using System; -using AutoMapper; - -namespace ProxyInterfaceConsumer -{ - public class PersonProxy2 : IPerson - { - public ProxyInterfaceConsumer.Person _Instance { get; } - - public int Id { get => _Instance.Id; } - - public object @object { get => _Instance.@object; set => _Instance.@object = value; } - - public long? NullableLong { get => _Instance.NullableLong; } - - public string Name { get => _Instance.Name; set => _Instance.Name = value; } - - public string? StringNullable { get => _Instance.StringNullable; set => _Instance.StringNullable = value; } - - public IAddress Address { get => _mapper.Map(_Instance.Address); set => _Instance.Address = _mapper.Map(value); } - - public System.Collections.Generic.List AddressesLIst { get => _mapper.Map>(_Instance.AddressesLIst); set => _Instance.AddressesLIst = _mapper.Map>(value); } - - public System.Collections.Generic.Dictionary AddressesDict { get => _mapper.Map>(_Instance.AddressesDict); set => _Instance.AddressesDict = _mapper.Map>(value); } - - public System.Collections.Generic.Dictionary AddressesDict2 { get => _mapper.Map>(_Instance.AddressesDict2); set => _Instance.AddressesDict2 = _mapper.Map>(value); } - - public ProxyInterfaceConsumer.E E { get => _Instance.E; set => _Instance.E = value; } - - public ProxyInterfaceConsumer.IMyInterface MyInterface { get => _Instance.MyInterface; set => _Instance.MyInterface = value; } - - - - public string Add(string s, string @string) - { - string s_ = s; - string @string_ = @string; - var result_33785274 = _Instance.Add(s_, @string_); - return result_33785274; - } - - public void AddWithParams(params string[] values) - { - string[] values_ = values; - _Instance.AddWithParams(values_); - } - - public IAddress AddAddress(IAddress a) - { - ProxyInterfaceConsumer.Address a_ = _mapper.Map(a); - var result_9487824 = _Instance.AddAddress(a_); - return _mapper.Map(result_9487824); - } - - public void AddAddresses(params ProxyInterfaceConsumer.Address[] addresses) - { - ProxyInterfaceConsumer.Address[] addresses_ = addresses; - _Instance.AddAddresses(addresses_); - } - - public void In_Out_Ref1(in int a, out int b, ref int c) - { - int a_ = a; - int b_; - int c_ = c; - _Instance.In_Out_Ref1(in a_, out b_, ref c_); - b = b_; - } - - public int In_Out_Ref2(in IAddress a, out IAddress b, ref IAddress c) - { - ProxyInterfaceConsumer.Address a_ = _mapper.Map(a); - ProxyInterfaceConsumer.Address b_; - ProxyInterfaceConsumer.Address c_ = _mapper.Map(c); - var result_30316242 = _Instance.In_Out_Ref2(in a_, out b_, ref c_); - b = _mapper.Map(b_); - return result_30316242; - } - - public void Void() - { - _Instance.Void(); - } - - public System.Threading.Tasks.Task Method1Async() - { - var result_19162058 = _Instance.Method1Async(); - return result_19162058; - } - - public System.Threading.Tasks.Task Method2Async() - { - var result_1349218716 = _Instance.Method2Async(); - return result_1349218716; - } - - public System.Threading.Tasks.Task Method3Async() - { - var result_1352687748 = _Instance.Method3Async(); - return result_1352687748; - } - - - - public PersonProxy2(ProxyInterfaceConsumer.Person instance) - { - _Instance = instance; - - _mapper = new MapperConfiguration(cfg => - { - cfg.CreateMap(); - cfg.CreateMap(); - }).CreateMapper(); - - } - - private readonly IMapper _mapper; -} -} \ No newline at end of file diff --git a/src-examples/ProxyInterfaceConsumerViaNuGet/ProxyInterfaceConsumerViaNuGet.csproj b/src-examples/ProxyInterfaceConsumerViaNuGet/ProxyInterfaceConsumerViaNuGet.csproj index 793f0dd..4ad7f2b 100644 --- a/src-examples/ProxyInterfaceConsumerViaNuGet/ProxyInterfaceConsumerViaNuGet.csproj +++ b/src-examples/ProxyInterfaceConsumerViaNuGet/ProxyInterfaceConsumerViaNuGet.csproj @@ -1,14 +1,18 @@ - - Exe - net5.0 - ProxyInterfaceConsumer - ProxyInterfaceConsumer - + + Exe + net7.0 + ProxyInterfaceConsumer + ProxyInterfaceConsumer + enable - - - + + + + + + + \ No newline at end of file diff --git a/src/ProxyInterfaceSourceGenerator/FileGenerators/ProxyAttributeGenerator.cs b/src/ProxyInterfaceSourceGenerator/FileGenerators/ExtraFilesGenerator.cs similarity index 55% rename from src/ProxyInterfaceSourceGenerator/FileGenerators/ProxyAttributeGenerator.cs rename to src/ProxyInterfaceSourceGenerator/FileGenerators/ExtraFilesGenerator.cs index 1e4f1c1..32f7a13 100644 --- a/src/ProxyInterfaceSourceGenerator/FileGenerators/ProxyAttributeGenerator.cs +++ b/src/ProxyInterfaceSourceGenerator/FileGenerators/ExtraFilesGenerator.cs @@ -1,60 +1,60 @@ -using ProxyInterfaceSourceGenerator.Models; - -namespace ProxyInterfaceSourceGenerator.FileGenerators; - -internal class ProxyAttributeGenerator : IFileGenerator -{ - private const string ClassName = "ProxyAttribute"; - - public FileData GenerateFile() - { - return new FileData($"ProxyInterfaceGenerator.{ClassName}.g.cs", $@"//---------------------------------------------------------------------------------------- -// -// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//---------------------------------------------------------------------------------------- - -using System; - -namespace ProxyInterfaceGenerator -{{ - [AttributeUsage(AttributeTargets.Interface)] - public class {ClassName} : Attribute - {{ - public Type Type {{ get; }} - public bool ProxyBaseClasses {{ get; }} - public ProxyClassAccessibility Accessibility {{ get; }} - - public {ClassName}(Type type) : this(type, false, ProxyClassAccessibility.Public) - {{ - }} - - public {ClassName}(Type type, bool proxyBaseClasses) : this(type, proxyBaseClasses, ProxyClassAccessibility.Public) - {{ - }} - - public {ClassName}(Type type, ProxyClassAccessibility accessibility) : this(type, false, accessibility) - {{ - }} - - public {ClassName}(Type type, bool proxyBaseClasses, ProxyClassAccessibility accessibility) - {{ - Type = type; - ProxyBaseClasses = proxyBaseClasses; - Accessibility = accessibility; - }} - }} - - [Flags] - public enum ProxyClassAccessibility - {{ - Public = 0, - - Internal = 1 - }} -}}"); - } +using ProxyInterfaceSourceGenerator.Models; + +namespace ProxyInterfaceSourceGenerator.FileGenerators; + +internal class ExtraFilesGenerator : IFileGenerator +{ + private const string Name = "ProxyInterfaceGenerator.Extra.g.cs"; + + public FileData GenerateFile() + { + return new FileData($"{Name}", $@"//---------------------------------------------------------------------------------------- +// +// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//---------------------------------------------------------------------------------------- + +using System; + +namespace ProxyInterfaceGenerator +{{ + [AttributeUsage(AttributeTargets.Interface)] + internal sealed class ProxyAttribute : Attribute + {{ + public Type Type {{ get; }} + public bool ProxyBaseClasses {{ get; }} + public ProxyClassAccessibility Accessibility {{ get; }} + + public ProxyAttribute(Type type) : this(type, false, ProxyClassAccessibility.Public) + {{ + }} + + public ProxyAttribute(Type type, bool proxyBaseClasses) : this(type, proxyBaseClasses, ProxyClassAccessibility.Public) + {{ + }} + + public ProxyAttribute(Type type, ProxyClassAccessibility accessibility) : this(type, false, accessibility) + {{ + }} + + public ProxyAttribute(Type type, bool proxyBaseClasses, ProxyClassAccessibility accessibility) + {{ + Type = type; + ProxyBaseClasses = proxyBaseClasses; + Accessibility = accessibility; + }} + }} + + [Flags] + internal enum ProxyClassAccessibility + {{ + Public = 0, + + Internal = 1 + }} +}}"); + } } \ No newline at end of file diff --git a/src/ProxyInterfaceSourceGenerator/ProxyInterfaceCodeGenerator.cs b/src/ProxyInterfaceSourceGenerator/ProxyInterfaceCodeGenerator.cs index a3daa46..3fed465 100644 --- a/src/ProxyInterfaceSourceGenerator/ProxyInterfaceCodeGenerator.cs +++ b/src/ProxyInterfaceSourceGenerator/ProxyInterfaceCodeGenerator.cs @@ -16,7 +16,7 @@ internal #endif class ProxyInterfaceCodeGenerator : ISourceGenerator { - private readonly ProxyAttributeGenerator _proxyAttributeGenerator = new (); + private readonly ExtraFilesGenerator _proxyAttributeGenerator = new (); public void Initialize(GeneratorInitializationContext context) { diff --git a/src/ProxyInterfaceSourceGenerator/ProxyInterfaceSourceGenerator.csproj b/src/ProxyInterfaceSourceGenerator/ProxyInterfaceSourceGenerator.csproj index a02ab98..c7c3eb9 100644 --- a/src/ProxyInterfaceSourceGenerator/ProxyInterfaceSourceGenerator.csproj +++ b/src/ProxyInterfaceSourceGenerator/ProxyInterfaceSourceGenerator.csproj @@ -1,7 +1,7 @@ - 0.0.33 + 0.0.34 netstandard2.0 {12344228-91F4-4502-9595-39584E5ABB34} 10