Skip to content

Commit e4487ee

Browse files
authored
Add blazor hint (when possible) (#248)
* re #247, add [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] (rev the build SDK so we can use NET5_0_OR_GREATER build symbol) * add release notes tweak
1 parent dc26897 commit e4487ee

File tree

5 files changed

+16
-3
lines changed

5 files changed

+16
-3
lines changed

appveyor.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ image: Visual Studio 2019
22

33
install:
44
- cmd: >-
5-
choco install dotnet-sdk --version 6.0.201
5+
choco install dotnet-sdk --version 6.0.302
66
77
skip_branch_with_pr: true
88
skip_tags: true

docs/releasenotes.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Release Notes
22

3+
## unreleased
4+
5+
- try to improve blazor linker support (i.e. avoid removal of necessary APIs)
6+
37
## 1.0.136
48

59
- add .NET 5 target

global.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
3-
"version": "3.0.100",
3+
"version": "6.0.302",
44
"rollForward": "latestMajor",
55
"allowPrerelease": false
66
}

src/protobuf-net.Grpc/Client/GrpcClientFactory.cs

+8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Grpc.Core;
22
using ProtoBuf.Grpc.Configuration;
33
using System;
4+
using System.Diagnostics.CodeAnalysis;
45
using System.Runtime.CompilerServices;
56

67
namespace ProtoBuf.Grpc.Client
@@ -10,6 +11,13 @@ namespace ProtoBuf.Grpc.Client
1011
/// </summary>
1112
public static class GrpcClientFactory
1213
{
14+
#if NET5_0_OR_GREATER
15+
// it is *intended* that this attribute usage will help the linker not remove things that we need
16+
// see: https://docs.microsoft.com/en-us/dotnet/core/deploying/trimming/prepare-libraries-for-trimming#dynamicallyaccessedmembers
17+
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]
18+
#endif
19+
internal static readonly Type ClientBaseType = typeof(ClientBase);
20+
1321
private const string SwitchAllowUnencryptedHttp2 = "System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport";
1422
/// <summary>
1523
/// Allows HttpClient to use HTTP/2 without TLS

src/protobuf-net.Grpc/Internal/ProxyEmitter.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Grpc.Core;
2+
using ProtoBuf.Grpc.Client;
23
using ProtoBuf.Grpc.Configuration;
34
using System;
45
using System.Collections.Generic;
@@ -135,7 +136,7 @@ internal static Func<CallInvoker, TService> CreateViaActivator<TService>(Type ty
135136
[MethodImpl(MethodImplOptions.NoInlining)]
136137
internal static Func<CallInvoker, TService> EmitFactory<TService>(BinderConfiguration binderConfig)
137138
{
138-
Type baseType = typeof(ClientBase);
139+
Type baseType = GrpcClientFactory.ClientBaseType;
139140

140141
var callInvoker = baseType.GetProperty("CallInvoker", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)?.GetGetMethod(true);
141142
if (callInvoker == null || callInvoker.ReturnType != typeof(CallInvoker) || callInvoker.GetParameters().Length != 0)

0 commit comments

Comments
 (0)