Skip to content

Commit 6f4925b

Browse files
committed
Merge in 'release/7.0' changes
2 parents d8d6a45 + ce5e4a8 commit 6f4925b

File tree

22 files changed

+366
-46
lines changed

22 files changed

+366
-46
lines changed

.github/CODEOWNERS

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22
# See https://help.github.com/articles/about-code-owners/
33

44
/**/PublicAPI.*Shipped.txt @dotnet/aspnet-api-review
5-
/global.json @dotnet/aspnet-build @dougbu @wtgodbe
6-
/.azure/ @dotnet/aspnet-build @dougbu @wtgodbe
7-
/.azuredevops/ @dotnet/aspnet-build @dougbu @wtgodbe
8-
/.config/ @dotnet/aspnet-build @dougbu @wtgodbe
9-
/.devcontainer/ @captainsafia @TanayParikh
10-
/.vscode/ @captainsafia @TanayParikh
11-
/.github/ @dotnet/aspnet-build @dougbu @wtgodbe
12-
/.github/*_TEMPLATE/ @dotnet/aspnet-build @dougbu @wtgodbe @mkArtakMSFT
13-
/.github/workflows/ @dotnet/aspnet-build @dougbu @wtgodbe @tratcher
5+
/global.json @dotnet/aspnet-build @wtgodbe
6+
/.azure/ @dotnet/aspnet-build @wtgodbe
7+
/.azuredevops/ @dotnet/aspnet-build @wtgodbe
8+
/.config/ @dotnet/aspnet-build @wtgodbe
9+
/.devcontainer/ @captainsafia
10+
/.vscode/ @captainsafia
11+
/.github/ @dotnet/aspnet-build @wtgodbe
12+
/.github/*_TEMPLATE/ @dotnet/aspnet-build @wtgodbe @mkArtakMSFT
13+
/.github/workflows/ @dotnet/aspnet-build @wtgodbe @tratcher
1414
/docs/ @captainsafia @mkArtakMSFT
15-
/eng/ @dotnet/aspnet-build @dougbu @wtgodbe
15+
/eng/ @dotnet/aspnet-build @wtgodbe
1616
/eng/common/ @dotnet-maestro-bot
17-
/eng/Versions.props @dotnet-maestro-bot @dotnet/aspnet-build @dougbu @wtgodbe
18-
/eng/Version.Details.xml @dotnet-maestro-bot @dotnet/aspnet-build @dougbu @wtgodbe
17+
/eng/Versions.props @dotnet-maestro-bot @dotnet/aspnet-build @wtgodbe
18+
/eng/Version.Details.xml @dotnet-maestro-bot @dotnet/aspnet-build @wtgodbe
1919
/src/Caching/ @captainsafia @halter73
2020
/src/Caching/**/PublicAPI.*Shipped.txt @dotnet/aspnet-api-review @captainsafia @halter73
2121
/src/Components/ @dotnet/aspnet-blazor-eng
@@ -49,4 +49,4 @@
4949
/src/Shared/test/Shared.Tests/runtime/ @dotnet/http
5050
/src/SignalR/ @BrennanConroy @halter73
5151
/src/SignalR/**/PublicAPI.*Shipped.txt @dotnet/aspnet-api-review @BrennanConroy @halter73
52-
/src/submodules @dotnet/aspnet-build @dougbu @wtgodbe
52+
/src/submodules @dotnet/aspnet-build @wtgodbe

src/Grpc/JsonTranscoding/src/Microsoft.AspNetCore.Grpc.JsonTranscoding/Internal/Binding/JsonTranscodingProviderServiceBinder.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System.Diagnostics.CodeAnalysis;
5-
using System.Linq;
65
using Google.Api;
76
using Google.Protobuf.Reflection;
87
using Grpc.AspNetCore.Server;

src/Grpc/JsonTranscoding/src/Microsoft.AspNetCore.Grpc.JsonTranscoding/Internal/Json/DurationConverter.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Text.Json;
55
using Google.Protobuf;
66
using Google.Protobuf.WellKnownTypes;
7+
using Grpc.Shared;
78
using Type = System.Type;
89

910
namespace Microsoft.AspNetCore.Grpc.JsonTranscoding.Internal.Json;

src/Grpc/JsonTranscoding/src/Microsoft.AspNetCore.Grpc.JsonTranscoding/Internal/Json/EnumConverter.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Runtime.CompilerServices;
66
using System.Text.Json;
77
using Google.Protobuf.Reflection;
8+
using Grpc.Shared;
89
using Type = System.Type;
910

1011
namespace Microsoft.AspNetCore.Grpc.JsonTranscoding.Internal.Json;

src/Grpc/JsonTranscoding/src/Microsoft.AspNetCore.Grpc.JsonTranscoding/Internal/Json/FieldMaskConverter.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Text.Json;
77
using Google.Protobuf;
88
using Google.Protobuf.WellKnownTypes;
9+
using Grpc.Shared;
910
using Type = System.Type;
1011

1112
namespace Microsoft.AspNetCore.Grpc.JsonTranscoding.Internal.Json;
@@ -43,7 +44,7 @@ public override void Write(Utf8JsonWriter writer, TMessage value, JsonSerializer
4344
var firstInvalid = paths.FirstOrDefault(p => !Legacy.IsPathValid(p));
4445
if (firstInvalid == null)
4546
{
46-
writer.WriteStringValue(string.Join(",", paths.Select(Legacy.ToJsonName)));
47+
writer.WriteStringValue(Legacy.GetFieldMaskText(paths));
4748
}
4849
else
4950
{

src/Grpc/JsonTranscoding/src/Microsoft.AspNetCore.Grpc.JsonTranscoding/Internal/Json/TimestampConverter.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Text.Json;
55
using Google.Protobuf;
66
using Google.Protobuf.WellKnownTypes;
7+
using Grpc.Shared;
78
using Type = System.Type;
89

910
namespace Microsoft.AspNetCore.Grpc.JsonTranscoding.Internal.Json;

src/Grpc/JsonTranscoding/src/Microsoft.AspNetCore.Grpc.JsonTranscoding/Internal/JsonRequestHelpers.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ private static async ValueTask<byte[]> ReadDataAsync(JsonTranscodingServerCallCo
338338
{
339339
return serverCallContext.DescriptorInfo.PathDescriptorsCache.GetOrAdd(path, p =>
340340
{
341-
ServiceDescriptorHelpers.TryResolveDescriptors(requestMessage.Descriptor, p.Split('.'), out var pathDescriptors);
341+
ServiceDescriptorHelpers.TryResolveDescriptors(requestMessage.Descriptor, p.Split('.'), allowJsonName: true, out var pathDescriptors);
342342
return pathDescriptors;
343343
});
344344
}

src/Grpc/JsonTranscoding/src/Microsoft.AspNetCore.Grpc.JsonTranscoding/Microsoft.AspNetCore.Grpc.JsonTranscoding.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<Compile Include="..\Shared\X509CertificateHelpers.cs" Link="Internal\Shared\X509CertificateHelpers.cs" />
2424
<Compile Include="..\Shared\HttpRoutePattern.cs" Link="Internal\Shared\HttpRoutePattern.cs" />
2525
<Compile Include="..\Shared\HttpRoutePatternParser.cs" Link="Internal\Shared\HttpRoutePatternParser.cs" />
26+
<Compile Include="..\Shared\Legacy.cs" Link="Internal\Shared\Legacy.cs" />
2627
<Compile Include="$(SharedSourceRoot)ValueTaskExtensions\**\*.cs" LinkBase="Internal\Shared" />
2728

2829
<Reference Include="Google.Api.CommonProtos" />

src/Grpc/JsonTranscoding/src/Microsoft.AspNetCore.Grpc.Swagger/Internal/GrpcDataContractResolver.cs

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System.Diagnostics.CodeAnalysis;
45
using System.Linq;
56
using System.Reflection;
67
using Google.Protobuf;
@@ -65,44 +66,62 @@ public DataContract GetDataContractForType(Type type)
6566
return _innerContractResolver.GetDataContractForType(type);
6667
}
6768

68-
private DataContract ConvertMessage(MessageDescriptor messageDescriptor)
69+
private bool TryCustomizeMessage(MessageDescriptor messageDescriptor, [NotNullWhen(true)] out DataContract? dataContract)
6970
{
71+
// The messages serialized here should be kept in sync with SericeDescriptionHelper.IsCustomType.
7072
if (ServiceDescriptorHelpers.IsWellKnownType(messageDescriptor))
7173
{
7274
if (ServiceDescriptorHelpers.IsWrapperType(messageDescriptor))
7375
{
7476
var field = messageDescriptor.Fields[Int32Value.ValueFieldNumber];
7577

76-
return _innerContractResolver.GetDataContractForType(MessageDescriptorHelpers.ResolveFieldType(field));
78+
dataContract = _innerContractResolver.GetDataContractForType(MessageDescriptorHelpers.ResolveFieldType(field));
79+
return true;
7780
}
7881
if (messageDescriptor.FullName == Timestamp.Descriptor.FullName ||
7982
messageDescriptor.FullName == Duration.Descriptor.FullName ||
8083
messageDescriptor.FullName == FieldMask.Descriptor.FullName)
8184
{
82-
return DataContract.ForPrimitive(messageDescriptor.ClrType, DataType.String, dataFormat: null);
85+
dataContract = DataContract.ForPrimitive(messageDescriptor.ClrType, DataType.String, dataFormat: null);
86+
return true;
8387
}
8488
if (messageDescriptor.FullName == Struct.Descriptor.FullName)
8589
{
86-
return DataContract.ForObject(messageDescriptor.ClrType, Array.Empty<DataProperty>(), extensionDataType: typeof(Value));
90+
dataContract = DataContract.ForObject(messageDescriptor.ClrType, Array.Empty<DataProperty>(), extensionDataType: typeof(Value));
91+
return true;
8792
}
8893
if (messageDescriptor.FullName == ListValue.Descriptor.FullName)
8994
{
90-
return DataContract.ForArray(messageDescriptor.ClrType, typeof(Value));
95+
dataContract = DataContract.ForArray(messageDescriptor.ClrType, typeof(Value));
96+
return true;
9197
}
9298
if (messageDescriptor.FullName == Value.Descriptor.FullName)
9399
{
94-
return DataContract.ForPrimitive(messageDescriptor.ClrType, DataType.Unknown, dataFormat: null);
100+
dataContract = DataContract.ForPrimitive(messageDescriptor.ClrType, DataType.Unknown, dataFormat: null);
101+
return true;
95102
}
96103
if (messageDescriptor.FullName == Any.Descriptor.FullName)
97104
{
98105
var anyProperties = new List<DataProperty>
99106
{
100107
new DataProperty("@type", typeof(string), isRequired: true)
101108
};
102-
return DataContract.ForObject(messageDescriptor.ClrType, anyProperties, extensionDataType: typeof(Value));
109+
dataContract = DataContract.ForObject(messageDescriptor.ClrType, anyProperties, extensionDataType: typeof(Value));
110+
return true;
103111
}
104112
}
105113

114+
dataContract = null;
115+
return false;
116+
}
117+
118+
private DataContract ConvertMessage(MessageDescriptor messageDescriptor)
119+
{
120+
if (TryCustomizeMessage(messageDescriptor, out var dataContract))
121+
{
122+
return dataContract;
123+
}
124+
106125
var properties = new List<DataProperty>();
107126

108127
foreach (var field in messageDescriptor.Fields.InFieldNumberOrder())

src/Grpc/JsonTranscoding/src/Microsoft.AspNetCore.Grpc.Swagger/Microsoft.AspNetCore.Grpc.Swagger.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<Description>Swagger for gRPC ASP.NET Core</Description>
44
<PackageTags>gRPC RPC HTTP/2 REST Swagger OpenAPI</PackageTags>
@@ -12,6 +12,7 @@
1212
<Compile Include="..\Shared\ServiceDescriptorHelpers.cs" Link="Internal\Shared\ServiceDescriptorHelpers.cs" />
1313
<Compile Include="..\Shared\HttpRoutePattern.cs" Link="Internal\Shared\HttpRoutePattern.cs" />
1414
<Compile Include="..\Shared\HttpRoutePatternParser.cs" Link="Internal\Shared\HttpRoutePatternParser.cs" />
15+
<Compile Include="..\Shared\Legacy.cs" Link="Internal\Shared\Legacy.cs" />
1516

1617
<Reference Include="Microsoft.AspNetCore.Grpc.JsonTranscoding" />
1718
<Reference Include="Swashbuckle.AspNetCore" />

0 commit comments

Comments
 (0)