Skip to content

Commit dcb9416

Browse files
author
machibuse
committed
Add Proto test projects and enhance TypeMapper logging and preprocessing
- Introduced `Porticle.Grpc.Test` and `Porticle.Grpc.TestWithoutProto` for manual testing. - Improved log messages in `ProtoPostProcessor` for better clarity. - Handled platform-specific path separator fixes with regex in filename processing. - Updated `TypeMapper` package version to 1.4.113. - Added configuration to treat warnings as errors in development builds. - Refined MSBuild task condition to check protobuf compile count.
1 parent 949e0b0 commit dcb9416

13 files changed

Lines changed: 337 additions & 11 deletions

File tree

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net9.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<Protobuf Include="SubDir\Test3.proto">
12+
<GrpcServices>Both</GrpcServices>
13+
<Access>Public</Access>
14+
<ProtoCompile>True</ProtoCompile>
15+
<CompileOutputs>True</CompileOutputs>
16+
<OutputDir>obj\Debug\net9.0\</OutputDir>
17+
<Generator>MSBuild:Compile</Generator>
18+
</Protobuf>
19+
<Protobuf Include="SubDir\Test2.proto">
20+
<GrpcServices>Both</GrpcServices>
21+
<Access>Public</Access>
22+
<ProtoCompile>True</ProtoCompile>
23+
<CompileOutputs>True</CompileOutputs>
24+
<OutputDir>obj\Debug\net9.0\</OutputDir>
25+
<Generator>MSBuild:Compile</Generator>
26+
</Protobuf>
27+
<Protobuf Include="Test1.proto">
28+
<GrpcServices>Both</GrpcServices>
29+
<Access>Public</Access>
30+
<ProtoCompile>True</ProtoCompile>
31+
<CompileOutputs>True</CompileOutputs>
32+
<OutputDir>obj\Debug\net9.0\</OutputDir>
33+
<Generator>MSBuild:Compile</Generator>
34+
</Protobuf>
35+
<Protobuf Include="Test2.proto">
36+
<GrpcServices>Both</GrpcServices>
37+
<Access>Public</Access>
38+
<ProtoCompile>True</ProtoCompile>
39+
<CompileOutputs>True</CompileOutputs>
40+
<OutputDir>obj\Debug\net9.0\</OutputDir>
41+
<Generator>MSBuild:Compile</Generator>
42+
</Protobuf>
43+
</ItemGroup>
44+
45+
<ItemGroup>
46+
<PackageReference Include="Google.Protobuf" Version="3.31.1"/>
47+
<PackageReference Include="Grpc.Tools" Version="2.72.0">
48+
<PrivateAssets>all</PrivateAssets>
49+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
50+
</PackageReference>
51+
<PackageReference Include="Porticle.Grpc.TypeMapper" Version="1.4.113">
52+
<PrivateAssets>all</PrivateAssets>
53+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
54+
</PackageReference>
55+
</ItemGroup>
56+
57+
</Project>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Console.WriteLine("Nothing here - only a test project for manual testing");
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
syntax = "proto3";
2+
3+
option csharp_namespace = "Porticle.Grpc.UnitTests.SubDir.Test2";
4+
5+
import "google/protobuf/wrappers.proto";
6+
7+
8+
message TestMessage2 {
9+
string single_guid = 1;
10+
google.protobuf.StringValue single_nullable_guid = 2;
11+
google.protobuf.StringValue single_nullable_string = 4;
12+
repeated string list_of_guid = 5;
13+
}
14+
15+
message TestMessageMapped2 {
16+
// [GrpcGuid]
17+
string single_guid = 1;
18+
19+
// [GrpcGuid]
20+
google.protobuf.StringValue single_nullable_guid = 2;
21+
22+
// [NullableString]
23+
google.protobuf.StringValue single_nullable_string = 4;
24+
25+
// [GrpcGuid]
26+
repeated string list_of_guid = 5;
27+
28+
TestEnum enum_required = 6;
29+
30+
// [NullableEnum]
31+
optional TestEnum enum_optional = 7;
32+
}
33+
34+
//////////////////////////////////////////////
35+
// Test comment to check marker comment
36+
//////////////////////////////////////////////
37+
message TestMessageEnum1 {
38+
optional TestEnum enum_optional = 7;
39+
}
40+
message TestMessageEnum2 {
41+
// [NullableEnum]
42+
optional TestEnum enum_optional = 7;
43+
}
44+
45+
46+
message TestMessageEnum3 {
47+
48+
optional TestEnum foo_bar = 7;
49+
}
50+
51+
52+
enum TestEnum
53+
{
54+
FOO = 0;
55+
BAR = 1;
56+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
syntax = "proto3";
2+
3+
option csharp_namespace = "Porticle.Grpc.UnitTests.SubDir.Test3";
4+
5+
6+
import "google/protobuf/wrappers.proto";
7+
8+
9+
message TestMessage {
10+
string single_guid = 1;
11+
google.protobuf.StringValue single_nullable_guid = 2;
12+
google.protobuf.StringValue single_nullable_string = 4;
13+
repeated string list_of_guid = 5;
14+
}
15+
16+
message TestMessageMapped {
17+
// [GrpcGuid]
18+
string single_guid = 1;
19+
20+
// [GrpcGuid]
21+
google.protobuf.StringValue single_nullable_guid = 2;
22+
23+
// [NullableString]
24+
google.protobuf.StringValue single_nullable_string = 4;
25+
26+
// [GrpcGuid]
27+
repeated string list_of_guid = 5;
28+
29+
TestEnum enum_required = 6;
30+
31+
// [NullableEnum]
32+
optional TestEnum enum_optional = 7;
33+
}
34+
35+
//////////////////////////////////////////////
36+
// Test comment to check marker comment
37+
//////////////////////////////////////////////
38+
message TestMessageEnum1 {
39+
optional TestEnum enum_optional = 7;
40+
}
41+
message TestMessageEnum2 {
42+
// [NullableEnum]
43+
optional TestEnum enum_optional = 7;
44+
}
45+
46+
47+
message TestMessageEnum3 {
48+
49+
optional TestEnum foo_bar = 7;
50+
}
51+
52+
53+
enum TestEnum
54+
{
55+
FOO = 0;
56+
BAR = 1;
57+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
syntax = "proto3";
2+
3+
option csharp_namespace = "Porticle.Grpc.UnitTests.Test1";
4+
5+
import "google/protobuf/wrappers.proto";
6+
7+
8+
message TestMessage {
9+
string single_guid = 1;
10+
google.protobuf.StringValue single_nullable_guid = 2;
11+
google.protobuf.StringValue single_nullable_string = 4;
12+
repeated string list_of_guid = 5;
13+
}
14+
15+
message TestMessageMapped {
16+
// [GrpcGuid]
17+
string single_guid = 1;
18+
19+
// [GrpcGuid]
20+
google.protobuf.StringValue single_nullable_guid = 2;
21+
22+
// [NullableString]
23+
google.protobuf.StringValue single_nullable_string = 4;
24+
25+
// [GrpcGuid]
26+
repeated string list_of_guid = 5;
27+
28+
TestEnum enum_required = 6;
29+
30+
// [NullableEnum]
31+
optional TestEnum enum_optional = 7;
32+
}
33+
34+
//////////////////////////////////////////////
35+
// Test comment to check marker comment
36+
//////////////////////////////////////////////
37+
message TestMessageEnum1 {
38+
optional TestEnum enum_optional = 7;
39+
}
40+
message TestMessageEnum2 {
41+
// [NullableEnum]
42+
optional TestEnum enum_optional = 7;
43+
}
44+
45+
46+
message TestMessageEnum3 {
47+
48+
optional TestEnum foo_bar = 7;
49+
}
50+
51+
52+
enum TestEnum
53+
{
54+
FOO = 0;
55+
BAR = 1;
56+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
syntax = "proto3";
2+
3+
option csharp_namespace = "Porticle.Grpc.UnitTests.Test2";
4+
5+
import "google/protobuf/wrappers.proto";
6+
7+
8+
message TestMessage2 {
9+
string single_guid = 1;
10+
google.protobuf.StringValue single_nullable_guid = 2;
11+
google.protobuf.StringValue single_nullable_string = 4;
12+
repeated string list_of_guid = 5;
13+
}
14+
15+
message TestMessageMapped2 {
16+
// [GrpcGuid]
17+
string single_guid = 1;
18+
19+
// [GrpcGuid]
20+
google.protobuf.StringValue single_nullable_guid = 2;
21+
22+
// [NullableString]
23+
google.protobuf.StringValue single_nullable_string = 4;
24+
25+
// [GrpcGuid]
26+
repeated string list_of_guid = 5;
27+
28+
TestEnum enum_required = 6;
29+
30+
// [NullableEnum]
31+
optional TestEnum enum_optional = 7;
32+
}
33+
34+
//////////////////////////////////////////////
35+
// Test comment to check marker comment
36+
//////////////////////////////////////////////
37+
message TestMessageEnum1 {
38+
optional TestEnum enum_optional = 7;
39+
}
40+
message TestMessageEnum2 {
41+
// [NullableEnum]
42+
optional TestEnum enum_optional = 7;
43+
}
44+
45+
46+
message TestMessageEnum3 {
47+
48+
optional TestEnum foo_bar = 7;
49+
}
50+
51+
52+
enum TestEnum
53+
{
54+
FOO = 0;
55+
BAR = 1;
56+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net9.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="Google.Protobuf" Version="3.31.1"/>
12+
<PackageReference Include="Grpc.Tools" Version="2.72.0">
13+
<PrivateAssets>all</PrivateAssets>
14+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
15+
</PackageReference>
16+
<PackageReference Include="Porticle.Grpc.TypeMapper" Version="1.4.111">
17+
<PrivateAssets>all</PrivateAssets>
18+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
19+
</PackageReference>
20+
</ItemGroup>
21+
22+
</Project>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Project without proto files, but Grpc.Tools installed
2+
3+
Console.WriteLine("Nothing here - only a test project for manual testing");

Source/Porticle.Grpc.TypeMapper/Porticle.Grpc.TypeMapper.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<PackageReleaseNotes></PackageReleaseNotes>
1616
<IncludeBuildOutput>false</IncludeBuildOutput>
1717
<DevelopmentDependency>true</DevelopmentDependency>
18-
<Version>1.3.4</Version>
18+
<Version>1.4.113</Version>
1919
<SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking>
2020
<TargetFrameworks>net9.0;net8.0</TargetFrameworks>
2121
<PackageReadmeFile>readme.md</PackageReadmeFile>
@@ -24,6 +24,7 @@
2424
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
2525
<WarningsAsErrors>NU1605</WarningsAsErrors>
2626
<NoWarn>1701;1702;NU5119</NoWarn>
27+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
2728
</PropertyGroup>
2829

2930
<ItemGroup>

Source/Porticle.Grpc.TypeMapper/Porticle.Grpc.TypeMapper.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
FilesToPostProcess="@(_FilesToPostProcess)"
99
WrapAllNonNullableStrings="$(PorticleGrpcTypeMapper_WrapAllNonNullableStrings)"
1010
WrapAllNullableStringValues="$(PorticleGrpcTypeMapper_WrapAllNullableStringValues)"
11-
Condition="'@(_FilesToPostProcess)' != ''"/>
11+
Condition="'@(Protobuf_Compile->Count())' != '0'"/>
1212
</Target>
1313
</Project>

0 commit comments

Comments
 (0)