Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add blazor hint (when possible) #248

Merged
merged 2 commits into from
Jul 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ image: Visual Studio 2019

install:
- cmd: >-
choco install dotnet-sdk --version 6.0.201
choco install dotnet-sdk --version 6.0.302

skip_branch_with_pr: true
skip_tags: true
Expand Down
4 changes: 4 additions & 0 deletions docs/releasenotes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release Notes

## unreleased

- try to improve blazor linker support (i.e. avoid removal of necessary APIs)

## 1.0.136

- add .NET 5 target
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "3.0.100",
"version": "6.0.302",
"rollForward": "latestMajor",
"allowPrerelease": false
}
Expand Down
8 changes: 8 additions & 0 deletions src/protobuf-net.Grpc/Client/GrpcClientFactory.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Grpc.Core;
using ProtoBuf.Grpc.Configuration;
using System;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;

namespace ProtoBuf.Grpc.Client
Expand All @@ -10,6 +11,13 @@ namespace ProtoBuf.Grpc.Client
/// </summary>
public static class GrpcClientFactory
{
#if NET5_0_OR_GREATER
// it is *intended* that this attribute usage will help the linker not remove things that we need
// see: https://docs.microsoft.com/en-us/dotnet/core/deploying/trimming/prepare-libraries-for-trimming#dynamicallyaccessedmembers
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]
#endif
internal static readonly Type ClientBaseType = typeof(ClientBase);

private const string SwitchAllowUnencryptedHttp2 = "System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport";
/// <summary>
/// Allows HttpClient to use HTTP/2 without TLS
Expand Down
3 changes: 2 additions & 1 deletion src/protobuf-net.Grpc/Internal/ProxyEmitter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Grpc.Core;
using ProtoBuf.Grpc.Client;
using ProtoBuf.Grpc.Configuration;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -135,7 +136,7 @@ internal static Func<CallInvoker, TService> CreateViaActivator<TService>(Type ty
[MethodImpl(MethodImplOptions.NoInlining)]
internal static Func<CallInvoker, TService> EmitFactory<TService>(BinderConfiguration binderConfig)
{
Type baseType = typeof(ClientBase);
Type baseType = GrpcClientFactory.ClientBaseType;

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