Skip to content

Commit 996fa62

Browse files
machibuseMachibuse
authored andcommitted
Initial
1 parent e4e171e commit 996fa62

4 files changed

Lines changed: 29 additions & 6 deletions

File tree

Source/Porticle.Grpc.GuidMapper/MethodVisitor.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,24 @@ public MethodVisitor(HashSet<PropertyToField> replaceProps)
1313

1414
public HashSet<PropertyToField> ReplaceProps { get; }
1515

16+
private static string[] ReplaceMethods =
17+
[
18+
"Equals",
19+
"GetHashCode",
20+
"WriteTo",
21+
"InternalWriteTo",
22+
"CalculateSize",
23+
"MergeFrom",
24+
"InternalMergeFrom"
25+
];
26+
1627
public override SyntaxNode? VisitMethodDeclaration(MethodDeclarationSyntax node)
1728
{
29+
if (!ReplaceMethods.Contains(node.Identifier.ValueText.Trim()))
30+
{
31+
return base.VisitMethodDeclaration(node);
32+
}
33+
1834
var propertyToFieldRewriter = new PropertyToFieldRewriter(ReplaceProps);
1935

2036
var newBody = (BlockSyntax?)propertyToFieldRewriter.Visit(node.Body);

Source/Porticle.Grpc.GuidMapper/Porticle.Grpc.GuidMapper.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net9.0</TargetFramework>
65
<ImplicitUsings>enable</ImplicitUsings>
76
<Nullable>enable</Nullable>
87
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
@@ -18,8 +17,9 @@
1817
<PackageReleaseNotes>First test version</PackageReleaseNotes>
1918
<IncludeBuildOutput>false</IncludeBuildOutput>
2019
<DevelopmentDependency>true</DevelopmentDependency>
21-
<Version>1.0.3</Version>
20+
<Version>1.0.11</Version>
2221
<SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking>
22+
<TargetFrameworks>net9.0;net8.0</TargetFrameworks>
2323
</PropertyGroup>
2424

2525
<ItemGroup>
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<Project>
22
<Target Name="RunProtoPostProcessing" AfterTargets="Protobuf_Compile">
33
<ItemGroup>
4-
<_FilesToPostProcess Include="%(Protobuf_Compile.CSharpFullPath)" />
4+
<_FilesToPostProcess Include="$(MSBuildProjectDirectory)\%(Protobuf_Compile.OutputDir)\%(Protobuf_Compile.Filename)" />
55
</ItemGroup>
6-
7-
<Exec Command="dotnet &quot;$(MSBuildThisFileDirectory)..\..\tools\$(TargetFramework)\Porticle.Grpc.GuidMapper.dll&quot; -- %(_FilesToPostProcess.Identity)" Condition="'@(_FilesToPostProcess)' != ''" />
6+
<Message Text="Proto Postprocessing" Importance="high" />
7+
<Exec Command="dotnet &quot;$(MSBuildThisFileDirectory)..\tools\$(TargetFramework)\Porticle.Grpc.GuidMapper.dll&quot; -- %(_FilesToPostProcess.Identity)" Condition="'@(_FilesToPostProcess)' != ''" />
88
</Target>
99
</Project>

Source/Porticle.Grpc.GuidMapper/Program.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
using Microsoft.CodeAnalysis.CSharp;
22
using Porticle.Grpc.GuidMapper;
33

4+
// filter out "--" arg
5+
args = args.Where(s => s != "--").ToArray();
6+
47
// Akzeptiert den Dateipfad als Argument
58
if (args.Length != 1)
69
{
7-
Console.WriteLine("Error: Extected exactly 1 arg but got " + args.Length);
10+
Console.WriteLine("Error: Expected exactly 1 arg but got " + args.Length);
11+
foreach (var arg in args)
12+
{
13+
Console.WriteLine("Error: arg[..] '"+arg+"'");
14+
}
815
return;
916
}
1017

0 commit comments

Comments
 (0)