diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index e138a0a..1669540 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - dotnet-version: ["8.0.x"] + dotnet-version: ["10.0.x"] steps: - uses: actions/checkout@v4 diff --git a/DecoratorGenerator.UnitTests/DecoratorGenerator.UnitTests.csproj b/DecoratorGenerator.UnitTests/DecoratorGenerator.UnitTests.csproj index 5ca0807..0deb65a 100644 --- a/DecoratorGenerator.UnitTests/DecoratorGenerator.UnitTests.csproj +++ b/DecoratorGenerator.UnitTests/DecoratorGenerator.UnitTests.csproj @@ -1,7 +1,7 @@ - net8.0 + net10.0 enable enable @@ -10,7 +10,6 @@ - @@ -29,6 +28,7 @@ + diff --git a/DecoratorGenerator.UnitTests/ITigerConstraints.cs b/DecoratorGenerator.UnitTests/ITigerConstraints.cs deleted file mode 100644 index fc2e13c..0000000 --- a/DecoratorGenerator.UnitTests/ITigerConstraints.cs +++ /dev/null @@ -1,11 +0,0 @@ -using DecoratorGenerator; - -namespace SampleLibrary; - -[Decorate] -public interface ITigerConstraints -{ - string Roar(); - - string Trait(T trait) where T : class, ICat, new(); -} \ No newline at end of file diff --git a/DecoratorGenerator.UnitTests/Tests.cs b/DecoratorGenerator.UnitTests/Tests.cs index 8f401dc..f3218bb 100644 --- a/DecoratorGenerator.UnitTests/Tests.cs +++ b/DecoratorGenerator.UnitTests/Tests.cs @@ -20,16 +20,17 @@ public void Setup() { [Test] public async Task OneInterface() { - var source = await ReadCSharpFile(); - var generated = await ReadCSharpFile(); + var source = await ReadCSharpFile(true); + var generated = await ReadCSharpFile(true); await new VerifyCS.Test { TestState = { - ReferenceAssemblies = ReferenceAssemblies.Net.Net60, + ReferenceAssemblies = ReferenceAssemblies.Net.Net90, AdditionalReferences = { implementationAssembly, + GetAssembly("TestLibrary") }, Sources = { source }, GeneratedSources = @@ -42,16 +43,17 @@ public async Task OneInterface() { [Test] public async Task OneInterface_Properties() { - var source = await ReadCSharpFile(); - var generated = await ReadCSharpFile(); + var source = await ReadCSharpFile(true); + var generated = await ReadCSharpFile(true); await new VerifyCS.Test { TestState = { - ReferenceAssemblies = ReferenceAssemblies.Net.Net60, + ReferenceAssemblies = ReferenceAssemblies.Net.Net90, AdditionalReferences = { implementationAssembly, + GetAssembly("TestLibrary") }, Sources = { source }, GeneratedSources = @@ -64,17 +66,17 @@ public async Task OneInterface_Properties() { [Test] public async Task OneInterface_Constraints() { - var source = await ReadCSharpFile(); - var generated = await ReadCSharpFile(); + var source = await ReadCSharpFileByName(true, "ITigerConstraints"); + var generated = await ReadCSharpFileByName(true, "TigerConstraintsDecorator.generated"); await new VerifyCS.Test { TestState = { - ReferenceAssemblies = ReferenceAssemblies.Net.Net60, + ReferenceAssemblies = ReferenceAssemblies.Net.Net90, AdditionalReferences = { implementationAssembly, - Assembly.GetExecutingAssembly() + GetAssembly("TestLibrary") }, Sources = { source }, GeneratedSources = @@ -87,16 +89,17 @@ public async Task OneInterface_Constraints() { [Test] public async Task OneInterface_NestedNamespace() { - var source = await ReadCSharpFile(); - var generated = await ReadCSharpFile(); + var source = await ReadCSharpFile(true); + var generated = await ReadCSharpFile(true); await new VerifyCS.Test { TestState = { - ReferenceAssemblies = ReferenceAssemblies.Net.Net60, + ReferenceAssemblies = ReferenceAssemblies.Net.Net90, AdditionalReferences = { implementationAssembly, + GetAssembly("TestLibrary") }, Sources = { source }, GeneratedSources = @@ -109,19 +112,20 @@ public async Task OneInterface_NestedNamespace() { [Test] public async Task TwoInterfaces() { - var sourceOne = await ReadCSharpFile(); - var sourceTwo = await ReadCSharpFile(); + var sourceOne = await ReadCSharpFile(true); + var sourceTwo = await ReadCSharpFile(true); - var generatedOne = await ReadCSharpFile(); - var generatedTwo = await ReadCSharpFile(); + var generatedOne = await ReadCSharpFile(true); + var generatedTwo = await ReadCSharpFile(true); await new VerifyCS.Test { TestState = { - ReferenceAssemblies = ReferenceAssemblies.Net.Net60, + ReferenceAssemblies = ReferenceAssemblies.Net.Net90, AdditionalReferences = { implementationAssembly, + GetAssembly("TestLibrary") }, Sources = { sourceOne, sourceTwo }, GeneratedSources = @@ -135,19 +139,20 @@ public async Task TwoInterfaces() { [Test] public async Task WrapperList() { - var source = await ReadCSharpFile(); - var wrapperList = await ReadCSharpFile(); - var generated = await ReadCSharpFile(); - var generatedThirdParty = await ReadCSharpFile(); + var source = await ReadCSharpFile(true); + var wrapperList = await ReadCSharpFile(true); + var generated = await ReadCSharpFile(true); + var generatedThirdParty = await ReadCSharpFileByName(true, "DynamoDBContextDecorator.generated"); await new VerifyCS.Test { TestState = { - ReferenceAssemblies = ReferenceAssemblies.Net.Net60, + ReferenceAssemblies = ReferenceAssemblies.Net.Net90, AdditionalReferences = { implementationAssembly, - GetAssembly("AWSSDK.DynamoDBv2") + GetAssembly("TestLibrary"), + Assembly.GetAssembly(typeof(DynamoDBContext)), }, Sources = { wrapperList, source }, GeneratedSources = @@ -164,13 +169,32 @@ private static Assembly GetAssembly(string name) { return Assembly.Load(implementationAssemblyName); } - private static async Task ReadCSharpFile() { - var currentDirectory = Directory.GetParent(Directory.GetParent(AppDomain.CurrentDomain.BaseDirectory).Parent.Parent.FullName); + private static async Task ReadCSharpFile(bool isTestLibrary) { + var filenameWithoutExtension = typeof(T).Name; + return await ReadCSharpFileByName(isTestLibrary, filenameWithoutExtension); + } + + private static async Task ReadCSharpFileByName(bool isTestLibrary, string filenameWithoutExtension) { + var searchPattern = $"{filenameWithoutExtension}*.cs"; + return await ReadFile(isTestLibrary, searchPattern); + } + + private static async Task ReadFile(bool isTestLibrary, string searchPattern) { + var currentDirectory = GetCurrentDirectory(); + + var targetDirectory = isTestLibrary ? GetTestLibraryDirectory(currentDirectory) : currentDirectory; - var searchPattern = $"{typeof(T).Name}*.cs"; - var file = currentDirectory.GetFiles(searchPattern).First(); + var file = targetDirectory.GetFiles(searchPattern).First(); using var fileReader = new StreamReader(file.OpenRead()); return await fileReader.ReadToEndAsync(); } -} \ No newline at end of file + + private static DirectoryInfo? GetCurrentDirectory() { + return Directory.GetParent(Directory.GetParent(AppDomain.CurrentDomain.BaseDirectory).Parent.Parent.FullName); + } + + private static DirectoryInfo GetTestLibraryDirectory(DirectoryInfo currentDirectory) { + return currentDirectory.Parent.GetDirectories("TestLibrary").First(); + } +} diff --git a/DecoratorGenerator.UnitTests/TigerConstraintsDecorator.generated.cs b/DecoratorGenerator.UnitTests/TigerConstraintsDecorator.generated.cs deleted file mode 100644 index c56342c..0000000 --- a/DecoratorGenerator.UnitTests/TigerConstraintsDecorator.generated.cs +++ /dev/null @@ -1,22 +0,0 @@ -// -#nullable restore -namespace SampleLibrary; - -public abstract class TigerConstraintsDecorator : ITigerConstraints -{ - private ITigerConstraints tigerConstraints; - - protected TigerConstraintsDecorator(ITigerConstraints tigerConstraints) { - this.tigerConstraints = tigerConstraints; - } - - - - public virtual string Roar() { - return tigerConstraints.Roar(); - } - - public virtual string Trait(T trait) where T : class, SampleLibrary.ICat, new() { - return tigerConstraints.Trait(trait); - } -} diff --git a/DecoratorGenerator.sln b/DecoratorGenerator.sln deleted file mode 100644 index 6f35dcd..0000000 --- a/DecoratorGenerator.sln +++ /dev/null @@ -1,54 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.3.32901.215 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleApp", "SampleApp\SampleApp.csproj", "{7D42984C-6E63-4CCA-B146-00520C8CE05B}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionItems", "SolutionItems", "{2957E82A-47D8-49BB-BA0E-EC05DD3FAB28}" - ProjectSection(SolutionItems) = preProject - .editorconfig = .editorconfig - EndProjectSection -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DecoratorGenerator", "DecoratorGenerator\DecoratorGenerator.csproj", "{AFE3BBB2-DDFB-4029-8D2D-0277B89B6EA8}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleLibrary", "SampleLibrary\SampleLibrary.csproj", "{75EC8F81-2573-4C1B-8924-0175D37B1909}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleLibrary2", "SampleLibrary2\SampleLibrary2.csproj", "{D47F814F-ADE0-4FA6-AA5D-AD5E5BE24BBA}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DecoratorGenerator.UnitTests", "DecoratorGenerator.UnitTests\DecoratorGenerator.UnitTests.csproj", "{E59C8BDC-6B5C-475A-BB51-11DF383ABA50}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {7D42984C-6E63-4CCA-B146-00520C8CE05B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7D42984C-6E63-4CCA-B146-00520C8CE05B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7D42984C-6E63-4CCA-B146-00520C8CE05B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7D42984C-6E63-4CCA-B146-00520C8CE05B}.Release|Any CPU.Build.0 = Release|Any CPU - {AFE3BBB2-DDFB-4029-8D2D-0277B89B6EA8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AFE3BBB2-DDFB-4029-8D2D-0277B89B6EA8}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AFE3BBB2-DDFB-4029-8D2D-0277B89B6EA8}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AFE3BBB2-DDFB-4029-8D2D-0277B89B6EA8}.Release|Any CPU.Build.0 = Release|Any CPU - {75EC8F81-2573-4C1B-8924-0175D37B1909}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {75EC8F81-2573-4C1B-8924-0175D37B1909}.Debug|Any CPU.Build.0 = Debug|Any CPU - {75EC8F81-2573-4C1B-8924-0175D37B1909}.Release|Any CPU.ActiveCfg = Release|Any CPU - {75EC8F81-2573-4C1B-8924-0175D37B1909}.Release|Any CPU.Build.0 = Release|Any CPU - {D47F814F-ADE0-4FA6-AA5D-AD5E5BE24BBA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D47F814F-ADE0-4FA6-AA5D-AD5E5BE24BBA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D47F814F-ADE0-4FA6-AA5D-AD5E5BE24BBA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D47F814F-ADE0-4FA6-AA5D-AD5E5BE24BBA}.Release|Any CPU.Build.0 = Release|Any CPU - {E59C8BDC-6B5C-475A-BB51-11DF383ABA50}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E59C8BDC-6B5C-475A-BB51-11DF383ABA50}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E59C8BDC-6B5C-475A-BB51-11DF383ABA50}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E59C8BDC-6B5C-475A-BB51-11DF383ABA50}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {F95187AE-54EC-4B66-9C83-76B246D6B511} - EndGlobalSection -EndGlobal diff --git a/DecoratorGenerator.slnx b/DecoratorGenerator.slnx new file mode 100644 index 0000000..20ba1b4 --- /dev/null +++ b/DecoratorGenerator.slnx @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/DecoratorGenerator/OutputGenerator.cs b/DecoratorGenerator/OutputGenerator.cs index d89906b..79fc462 100644 --- a/DecoratorGenerator/OutputGenerator.cs +++ b/DecoratorGenerator/OutputGenerator.cs @@ -1,16 +1,18 @@ using Microsoft.CodeAnalysis; using System.Collections.Generic; +using System.Collections.Immutable; using System.Linq; namespace DecoratorGenerator { internal static class OutputGenerator { - public static (string source, string className) GenerateOutputs(INamedTypeSymbol type) { - var className = $"{type.Name.Substring(1)}Decorator"; - var @interface = type; + public static (string source, string className) GenerateOutputs(INamedTypeSymbol @interface) { + var className = $"{@interface.Name.Substring(1)}Decorator"; + var formattedConstraintTypes = FormatInterfaceConstraintTypes(@interface); + var formattedConstraints = CreateFormattedConstraints(@interface.TypeParameters); var targetFieldName = $@"{char.ToLower(@interface.Name[1])}{@interface.Name.Substring(2)}"; - var ancestorInterfaces = type.AllInterfaces; + var ancestorInterfaces = @interface.AllInterfaces; var ancestorMembers = ancestorInterfaces.SelectMany(a => a.GetMembers()); var members = @interface.GetMembers().Concat(ancestorMembers); var displayMethods = CreateDisplayMethods(targetFieldName, members); @@ -21,13 +23,13 @@ public static (string source, string className) GenerateOutputs(INamedTypeSymbol var source = $@"// #nullable restore -namespace {type.ContainingNamespace.ToDisplayString()}; +namespace {@interface.ContainingNamespace.ToDisplayString()}; -public abstract class {className} : {@interface.Name} +public abstract class {className}{formattedConstraintTypes} : {@interface.Name}{formattedConstraintTypes}{(formattedConstraints != string.Empty ? $@" {formattedConstraints}" : string.Empty)} {{ - private {@interface.Name} {targetFieldName}; + private {@interface.Name}{formattedConstraintTypes} {targetFieldName}; - protected {className}({@interface.Name} {targetFieldName}) {{ + protected {className}({@interface.Name}{formattedConstraintTypes} {targetFieldName}) {{ this.{targetFieldName} = {targetFieldName}; }} @@ -44,6 +46,12 @@ public abstract class {className} : {@interface.Name} return (source, className); } + private static string FormatInterfaceConstraintTypes(INamedTypeSymbol @interface) { + return @interface.TypeParameters.Any() + ? $"<{string.Join(", ", @interface.TypeParameters.Select(typeParameter => typeParameter.Name))}>" + : string.Empty; + } + private static IEnumerable<(string signature, string call, ITypeSymbol returnType)> CreateDisplayMethods(string targetFieldName, IEnumerable members) { var methods = members.Where(member => member is IMethodSymbol && !((member as IMethodSymbol).AssociatedSymbol is IPropertySymbol)).Select(m => m as IMethodSymbol); @@ -52,26 +60,7 @@ public abstract class {className} : {@interface.Name} var parametersStrings = method.Parameters.Select(p => $@"{p.Type} {p.Name}"); var formattedAccessibility = (method.ReturnType.DeclaredAccessibility != Accessibility.NotApplicable ? method.ReturnType.DeclaredAccessibility : Accessibility.Public).ToString().ToLower(); var formattedGenericTypeParameters = method.IsGenericMethod ? $@"<{string.Join(", ", typeParametersStrings)}>" : string.Empty; - var formattedConstraintsStrings = method.TypeParameters.Select(t => { - var constraintsStrings = new List(); - - if (t.HasReferenceTypeConstraint) { - constraintsStrings.Add("class"); - } - - if (t.HasNotNullConstraint) { - constraintsStrings.Add("notnull"); - } - constraintsStrings = constraintsStrings.Concat(t.ConstraintTypes.ToList().Select(ct => ct.ToDisplayString())).ToList(); - - if (t.HasConstructorConstraint) { - constraintsStrings.Add("new()"); - } - - return constraintsStrings.Any() ? $@"where {t.ToDisplayString()} : {string.Join(", ", constraintsStrings)}" : string.Empty; - }) - .Where(cs => cs != string.Empty); - var formattedConstraints = string.Join(" ", formattedConstraintsStrings); + var formattedConstraints = CreateFormattedConstraints(method.TypeParameters); var signature = $@"{formattedAccessibility} virtual {method.ReturnType} {method.Name}{formattedGenericTypeParameters}({string.Join(", ", parametersStrings)}){(formattedConstraints != string.Empty ? $@" {formattedConstraints}" : string.Empty)}"; var callParameters = $@"{string.Join(", ", method.Parameters.Select(p => p.Name))}"; @@ -82,6 +71,30 @@ public abstract class {className} : {@interface.Name} return displayMethods; } + private static string CreateFormattedConstraints(ImmutableArray typeParameters) { + var formattedConstraintsStrings = typeParameters.Select(t => { + var constraintsStrings = new List(); + + if (t.HasReferenceTypeConstraint) { + constraintsStrings.Add("class"); + } + + if (t.HasNotNullConstraint) { + constraintsStrings.Add("notnull"); + } + constraintsStrings = constraintsStrings.Concat(t.ConstraintTypes.ToList().Select(ct => ct.ToDisplayString())).ToList(); + + if (t.HasConstructorConstraint) { + constraintsStrings.Add("new()"); + } + + return constraintsStrings.Any() ? $@"where {t.ToDisplayString()} : {string.Join(", ", constraintsStrings)}" : string.Empty; + }) + .Where(cs => cs != string.Empty); + var formattedConstraints = string.Join(" ", formattedConstraintsStrings); + return formattedConstraints; + } + private static IEnumerable<(string signature, string call, string Empty)> CreateDisplayProperties(string targetFieldName, IEnumerable members) { var properties = members.Where(member => member is IPropertySymbol).Select(m => m as IPropertySymbol); var displayProperties = properties.Select(property => { diff --git a/SampleApp/SampleApp.csproj b/SampleApp/SampleApp.csproj index 53cc7ee..91b2e7a 100644 --- a/SampleApp/SampleApp.csproj +++ b/SampleApp/SampleApp.csproj @@ -2,7 +2,7 @@ Exe - net7.0 + net10.0 enable enable diff --git a/SampleLibrary2/IBird.cs b/SampleLibrary2/IBird.cs deleted file mode 100644 index b2d6005..0000000 --- a/SampleLibrary2/IBird.cs +++ /dev/null @@ -1,9 +0,0 @@ -using DecoratorGenerator; - -namespace SampleLibrary2; - -[Decorate] -public interface IBird -{ - string Chirp(); -} diff --git a/SampleLibrary2/Squawk.cs b/SampleLibrary2/Squawk.cs deleted file mode 100644 index 414d0e5..0000000 --- a/SampleLibrary2/Squawk.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace SampleLibrary2; -public class Squawk : BirdDecorator -{ - public Squawk(IBird bird) : base(bird) - { - } - - public override string Chirp() - { - return $"squawk {base.Chirp()}"; - } -} diff --git a/DecoratorGenerator.UnitTests/BirdDecorator.generated.cs b/TestLibrary/BirdDecorator.generated.cs similarity index 100% rename from DecoratorGenerator.UnitTests/BirdDecorator.generated.cs rename to TestLibrary/BirdDecorator.generated.cs diff --git a/DecoratorGenerator.UnitTests/CatDecorator.generated.cs b/TestLibrary/CatDecorator.generated.cs similarity index 100% rename from DecoratorGenerator.UnitTests/CatDecorator.generated.cs rename to TestLibrary/CatDecorator.generated.cs diff --git a/TestLibrary/Directory.Build.props b/TestLibrary/Directory.Build.props new file mode 100644 index 0000000..5d6cf9b --- /dev/null +++ b/TestLibrary/Directory.Build.props @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/DecoratorGenerator.UnitTests/DynamoDBContextDecorator.generated.cs b/TestLibrary/DynamoDBContextDecorator.generated.cs similarity index 100% rename from DecoratorGenerator.UnitTests/DynamoDBContextDecorator.generated.cs rename to TestLibrary/DynamoDBContextDecorator.generated.cs diff --git a/DecoratorGenerator.UnitTests/IBird.cs b/TestLibrary/IBird.cs similarity index 100% rename from DecoratorGenerator.UnitTests/IBird.cs rename to TestLibrary/IBird.cs diff --git a/DecoratorGenerator.UnitTests/ICat.cs b/TestLibrary/ICat.cs similarity index 100% rename from DecoratorGenerator.UnitTests/ICat.cs rename to TestLibrary/ICat.cs diff --git a/DecoratorGenerator.UnitTests/ILionProperties.cs b/TestLibrary/ILionProperties.cs similarity index 100% rename from DecoratorGenerator.UnitTests/ILionProperties.cs rename to TestLibrary/ILionProperties.cs diff --git a/DecoratorGenerator.UnitTests/INested.cs b/TestLibrary/INested.cs similarity index 100% rename from DecoratorGenerator.UnitTests/INested.cs rename to TestLibrary/INested.cs diff --git a/TestLibrary/ITigerConstraints.cs b/TestLibrary/ITigerConstraints.cs new file mode 100644 index 0000000..99d7cc5 --- /dev/null +++ b/TestLibrary/ITigerConstraints.cs @@ -0,0 +1,11 @@ +using DecoratorGenerator; + +namespace SampleLibrary; + +[Decorate] +public interface ITigerConstraints where T : class, ICat, new() +{ + string Roar(); + + string Trait(U trait) where U : class, ICat, new(); +} \ No newline at end of file diff --git a/DecoratorGenerator.UnitTests/LionPropertiesDecorator.generated.cs b/TestLibrary/LionPropertiesDecorator.generated.cs similarity index 100% rename from DecoratorGenerator.UnitTests/LionPropertiesDecorator.generated.cs rename to TestLibrary/LionPropertiesDecorator.generated.cs diff --git a/DecoratorGenerator.UnitTests/NestedDecorator.generated.cs b/TestLibrary/NestedDecorator.generated.cs similarity index 100% rename from DecoratorGenerator.UnitTests/NestedDecorator.generated.cs rename to TestLibrary/NestedDecorator.generated.cs diff --git a/SampleLibrary2/SampleLibrary2.csproj b/TestLibrary/TestLibrary.csproj similarity index 51% rename from SampleLibrary2/SampleLibrary2.csproj rename to TestLibrary/TestLibrary.csproj index be433e7..32fa678 100644 --- a/SampleLibrary2/SampleLibrary2.csproj +++ b/TestLibrary/TestLibrary.csproj @@ -1,13 +1,17 @@ - + - net7.0 + net10.0 enable enable - + + + + + diff --git a/TestLibrary/TigerConstraintsDecorator.generated.cs b/TestLibrary/TigerConstraintsDecorator.generated.cs new file mode 100644 index 0000000..92a4e20 --- /dev/null +++ b/TestLibrary/TigerConstraintsDecorator.generated.cs @@ -0,0 +1,22 @@ +// +#nullable restore +namespace SampleLibrary; + +public abstract class TigerConstraintsDecorator : ITigerConstraints where T : class, SampleLibrary.ICat, new() +{ + private ITigerConstraints tigerConstraints; + + protected TigerConstraintsDecorator(ITigerConstraints tigerConstraints) { + this.tigerConstraints = tigerConstraints; + } + + + + public virtual string Roar() { + return tigerConstraints.Roar(); + } + + public virtual string Trait(U trait) where U : class, SampleLibrary.ICat, new() { + return tigerConstraints.Trait(trait); + } +} diff --git a/DecoratorGenerator.UnitTests/WrapperList.cs b/TestLibrary/WrapperList.cs similarity index 100% rename from DecoratorGenerator.UnitTests/WrapperList.cs rename to TestLibrary/WrapperList.cs