Provide runtime/framework info in gRPC C# user agent string#25889
Provide runtime/framework info in gRPC C# user agent string#25889jtattermusch merged 3 commits intogrpc:masterfrom
Conversation
3deecb3 to
168b1a8
Compare
|
CC @srini100 |
|
FYI @jskeet |
apolcyn
left a comment
There was a problem hiding this comment.
LGTM, comments are minor
| detailComponents.Add($"CLR {clrVersion}"); | ||
| } | ||
|
|
||
| if (tfm != null) |
There was a problem hiding this comment.
optional nit: I believe tfm can never be null except for in unit tests, so this null check may be unnecessary
There was a problem hiding this comment.
you're right but I added the null check for consistency.
|
|
||
| static string TryGetArchitectureString(CommonPlatformDetection.CpuArchitecture arch) | ||
| { | ||
| switch (arch) |
There was a problem hiding this comment.
nit: can we get rid of this switch statement and just call ToString() on these enums? Then, we also don't need to check if this is null when constructing the user agent (I believe the architecture will just say "Unknown", which may be useful anyways)
| } | ||
| } | ||
|
|
||
| var result = string.Join(" ", parts.GetRange(0, i)); |
There was a problem hiding this comment.
nit: move this string.Join(" ", parts.GetRange(0, i)); assignment to line 105, just before breaking out of the loop? Then, we can keep i as a loop-local
There was a problem hiding this comment.
That actually wouldn't work when all the parts are acceptable strings (e.g. the string is just ".NET Framework 4.5" since if (!Regex.IsMatch(part, @"^[-.,+@A-Za-z0-9]*$")) would never be true.
|
Updated TryGetArchitectureString(). |
Make the user-agent string generated by the grpc-csharp client more useful by including info about the .NET Framework version in use, TFM, process architecture etc.
Example values of user-agent string:
MacOS:
Mono:
grpc-csharp/2.38.0-dev (Mono 5.20.1.19; CLR 4.0.30319.42000; net45; x64) grpc-c/16.0.0 (osx; chttp2).NET Core
grpc-csharp/2.38.0-dev (.NET Core 4.6.27617.05; CLR 4.0.30319.42000; netstandard2.0; x64) grpc-c/16.0.0 (osx; chttp2)Linux:
Mono:
grpc-csharp/2.38.0-dev (Mono 6.12.0.122; CLR 4.0.30319.42000; net45; x64) grpc-c/16.0.0 (linux; chttp2).NET Core
grpc-csharp/2.38.0-dev (.NET Core 4.6.27019.06; CLR 4.0.30319.42000; netstandard2.0; x64) grpc-c/16.0.0 (linux; chttp2)Windows:
.NET Framework ("full framework")
grpc-csharp/2.38.0-dev (.NET Framework 4.7.3163.0; CLR 4.0.30319.42000; net45; x64) grpc-c/16.0.0 (windows; chttp2).NET Core:
grpc-csharp/2.38.0-dev (.NET Core 4.6.27317.03; CLR 4.0.30319.42000; netstandard2.0; x64) grpc-c/16.0.0 (windows; chttp2)Values on .NET Core 3.x and newer:
grpc-csharp/2.38.0-dev (.NET Core 3.1.8; CLR 3.1.8; netstandard2.0; x64) grpc-c/16.0.0 (osx; chttp2)grpc-csharp/2.38.0-dev (.NET 5.0.0; CLR 5.0.0; netstandard2.0; x64) grpc-c/16.0.0 (osx; chttp2)Known limitations: