Skip to content

Commit

Permalink
New staticextensiongenerator behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
ramoneeza committed Jul 11, 2023
1 parent 5582baa commit d1f00c8
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 19 deletions.
6 changes: 4 additions & 2 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,10 @@ Rop.StaticExtensionGenerator
Rop.StaticExtensionGenerator is a source generator package to automatic static extension methods.
It can be used to provide static extension methods to classes. The current c# languaje does not allow to create static extension methods.

-The class to contain the static extension must be a generic class where the first generic type is the type class to be extended.
-The class where implement the static extension must be decorated with the attribute `[StaticExtension<MyStaticExtension<T,...>>()]`
-The static method to contain the static extension must be a generic class where the first generic type is the type class to be extended.
-This method has to be decorated with the attribute `[StaticExtension]`
-This method has to be included in one of the base class of the class to be extended.
-The class where implement the static extension must be decorated with the attribute `[InsertStaticExtensions]`

The nuget package Rop.StaticExtensionGenerator.Annotations is required in order to use the attributes.

Expand Down
7 changes: 7 additions & 0 deletions Rop.Generators.sln
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Rop.StaticExtension.Annotat
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test.ControllerGenerator", "Test\Test.ControllerGenerator\Test.ControllerGenerator.csproj", "{7EBAA8C5-695E-40CB-885B-B907929C7702}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test.SubDll", "Test\Test.SubDll\Test.SubDll.csproj", "{05FADFDF-5E2E-4088-A7E9-B4F8F6A8CAE7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -126,6 +128,10 @@ Global
{7EBAA8C5-695E-40CB-885B-B907929C7702}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7EBAA8C5-695E-40CB-885B-B907929C7702}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7EBAA8C5-695E-40CB-885B-B907929C7702}.Release|Any CPU.Build.0 = Release|Any CPU
{05FADFDF-5E2E-4088-A7E9-B4F8F6A8CAE7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{05FADFDF-5E2E-4088-A7E9-B4F8F6A8CAE7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{05FADFDF-5E2E-4088-A7E9-B4F8F6A8CAE7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{05FADFDF-5E2E-4088-A7E9-B4F8F6A8CAE7}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -137,6 +143,7 @@ Global
{3823745B-AED0-402E-AE0B-2277E3A24A34} = {F10EFED0-5CB0-40A6-849D-ADD8A497A930}
{1323FB30-4474-488B-AC84-E22ED4887040} = {F10EFED0-5CB0-40A6-849D-ADD8A497A930}
{7EBAA8C5-695E-40CB-885B-B907929C7702} = {F10EFED0-5CB0-40A6-849D-ADD8A497A930}
{05FADFDF-5E2E-4088-A7E9-B4F8F6A8CAE7} = {F10EFED0-5CB0-40A6-849D-ADD8A497A930}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {28136F61-670C-48E3-872A-9242018602A1}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<PackageTags>helper-classes;static;extensions;annotations</PackageTags>
<Description>Annotations for decorate Static Extension Generator</Description>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>1.0.2</Version>
<Version>1.0.3</Version>
<Authors>Ramon Ordiales Plaza</Authors>
<Company>Ramon Ordiales Plaza</Company>
<Copyright>2023 Ramon Ordiales</Copyright>
Expand Down
5 changes: 4 additions & 1 deletion Rop.StaticExtensionGenerator/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
},
"DebugComponent": {
"commandName": "DebugRoslynComponent",
"targetProject": "E:\\Dropbox\\ROAMING\\Visual Studio 2022\\Snippers\\Rop.Generators\\Test\\Test.StaticExtension\\Test.StaticExtensions.csproj"
"targetProject": "E:\\Dropbox\\ROAMING\\Visual Studio 2022\\Snippers\\Rop.Generators\\Test\\Test.StaticExtension\\Test.StaticExtensions.csproj",
"environmentVariables": {
"RunAfterBuild": "pause"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<PackageTags>extensions;generics;static;winforms;source-generator;roslyn</PackageTags>
<Description>Source generator to create static extensions</Description>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>1.0.3</Version>
<Version>1.0.4</Version>
<Authors>Ramon Ordiales Plaza</Authors>
<Company>Ramon Ordiales Plaza</Company>
<Copyright>2023 Ramon Ordiales</Copyright>
Expand Down
2 changes: 1 addition & 1 deletion Test/Test.StaticExtension/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ public void Hola()
}
}

public class BaseFormIntBool : BaseForm<int, bool>
public class BaseFormIntBool : Test.SubDll.BaseForm<int, bool>
{
}
11 changes: 0 additions & 11 deletions Test/Test.StaticExtension/MyStaticExtension.cs

This file was deleted.

2 changes: 1 addition & 1 deletion Test/Test.StaticExtension/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ internal class Program
private static void Main(string[] args)
{
Console.WriteLine("Hello, World!");
//Form1.Execute(true);
Form1.Execute(true);
}
}
1 change: 1 addition & 0 deletions Test/Test.StaticExtension/Test.StaticExtensions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<ItemGroup>
<ProjectReference Include="..\..\Rop.StaticExtension.Annotations\Rop.StaticExtension.Annotations.csproj" />
<ProjectReference Include="..\..\Rop.StaticExtensionGenerator\Rop.StaticExtensionGenerator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
<ProjectReference Include="..\Test.SubDll\Test.SubDll.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Rop.StaticExtension.Annotations;

namespace Test.StaticExtensions;
namespace Test.SubDll;

public class BaseForm<A, B>
{
Expand Down
13 changes: 13 additions & 0 deletions Test/Test.SubDll/Test.SubDll.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\Rop.StaticExtension.Annotations\Rop.StaticExtension.Annotations.csproj" />
</ItemGroup>

</Project>

0 comments on commit d1f00c8

Please sign in to comment.