diff options
author | Jan Tattermusch <jtattermusch@users.noreply.github.com> | 2016-10-22 10:04:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-22 10:04:12 +0200 |
commit | 8834095e7642310cc09c43ccf5ec0184bd48a5cd (patch) | |
tree | fc1efe711abcdb6fb7cbf957906002108974a396 | |
parent | 99e61f884d0c2b1e1e2af9a41ec2018b47041fec (diff) | |
parent | 9f254c0c40f85702221d2b14de7dd8b7cdac5cba (diff) |
Merge pull request #8438 from jtattermusch/csharp_compiler_warnings
Fix a few C# compiler warnings
-rw-r--r-- | src/csharp/Grpc.Auth/GoogleAuthInterceptors.cs | 4 | ||||
-rw-r--r-- | src/csharp/Grpc.Core/DefaultCallInvoker.cs | 1 | ||||
-rw-r--r-- | src/csharp/Grpc.Core/GrpcEnvironment.cs | 1 | ||||
-rw-r--r-- | src/csharp/Grpc.Core/Internal/InterceptingCallInvoker.cs | 2 | ||||
-rw-r--r-- | src/csharp/Grpc.Core/Internal/NativeMetadataCredentialsPlugin.cs | 7 | ||||
-rw-r--r-- | src/csharp/Grpc.Core/Internal/UnmanagedLibrary.cs | 6 | ||||
-rw-r--r-- | src/csharp/Grpc.Core/Metadata.cs | 43 |
7 files changed, 58 insertions, 6 deletions
diff --git a/src/csharp/Grpc.Auth/GoogleAuthInterceptors.cs b/src/csharp/Grpc.Auth/GoogleAuthInterceptors.cs index 96d6ee87ae..722b51f470 100644 --- a/src/csharp/Grpc.Auth/GoogleAuthInterceptors.cs +++ b/src/csharp/Grpc.Auth/GoogleAuthInterceptors.cs @@ -33,6 +33,7 @@ using System; using System.Threading; +using System.Threading.Tasks; using Google.Apis.Auth.OAuth2; using Grpc.Core; @@ -72,9 +73,10 @@ namespace Grpc.Auth public static AsyncAuthInterceptor FromAccessToken(string accessToken) { GrpcPreconditions.CheckNotNull(accessToken); - return new AsyncAuthInterceptor(async (context, metadata) => + return new AsyncAuthInterceptor((context, metadata) => { metadata.Add(CreateBearerTokenHeader(accessToken)); + return Task.FromResult<object>(null); }); } diff --git a/src/csharp/Grpc.Core/DefaultCallInvoker.cs b/src/csharp/Grpc.Core/DefaultCallInvoker.cs index 1a99e41153..b15aaefcd6 100644 --- a/src/csharp/Grpc.Core/DefaultCallInvoker.cs +++ b/src/csharp/Grpc.Core/DefaultCallInvoker.cs @@ -102,6 +102,7 @@ namespace Grpc.Core return Calls.AsyncDuplexStreamingCall(call); } + /// <summary>Creates call invocation details for given method.</summary> protected virtual CallInvocationDetails<TRequest, TResponse> CreateCall<TRequest, TResponse>(Method<TRequest, TResponse> method, string host, CallOptions options) where TRequest : class where TResponse : class diff --git a/src/csharp/Grpc.Core/GrpcEnvironment.cs b/src/csharp/Grpc.Core/GrpcEnvironment.cs index 3ed2df203d..c57c904eb9 100644 --- a/src/csharp/Grpc.Core/GrpcEnvironment.cs +++ b/src/csharp/Grpc.Core/GrpcEnvironment.cs @@ -59,7 +59,6 @@ namespace Grpc.Core static ILogger logger = new NullLogger(); - readonly object myLock = new object(); readonly GrpcThreadPool threadPool; readonly DebugStats debugStats = new DebugStats(); readonly AtomicCounter cqPickerCounter = new AtomicCounter(); diff --git a/src/csharp/Grpc.Core/Internal/InterceptingCallInvoker.cs b/src/csharp/Grpc.Core/Internal/InterceptingCallInvoker.cs index ef48dc7121..0c63e2092a 100644 --- a/src/csharp/Grpc.Core/Internal/InterceptingCallInvoker.cs +++ b/src/csharp/Grpc.Core/Internal/InterceptingCallInvoker.cs @@ -48,7 +48,7 @@ namespace Grpc.Core.Internal readonly Func<CallOptions, CallOptions> callOptionsInterceptor; /// <summary> - /// Initializes a new instance of the <see cref="Grpc.Core.InterceptingCallInvoker"/> class. + /// Initializes a new instance of the <see cref="Grpc.Core.Internal.InterceptingCallInvoker"/> class. /// </summary> public InterceptingCallInvoker(CallInvoker callInvoker, Func<string, string> hostInterceptor = null, diff --git a/src/csharp/Grpc.Core/Internal/NativeMetadataCredentialsPlugin.cs b/src/csharp/Grpc.Core/Internal/NativeMetadataCredentialsPlugin.cs index 26af6311d5..b3714481eb 100644 --- a/src/csharp/Grpc.Core/Internal/NativeMetadataCredentialsPlugin.cs +++ b/src/csharp/Grpc.Core/Internal/NativeMetadataCredentialsPlugin.cs @@ -78,7 +78,10 @@ namespace Grpc.Core.Internal { var context = new AuthInterceptorContext(Marshal.PtrToStringAnsi(serviceUrlPtr), Marshal.PtrToStringAnsi(methodNamePtr)); - StartGetMetadata(context, callbackPtr, userDataPtr); + // Don't await, we are in a native callback and need to return. + #pragma warning disable 4014 + GetMetadataAsync(context, callbackPtr, userDataPtr); + #pragma warning restore 4014 } catch (Exception e) { @@ -87,7 +90,7 @@ namespace Grpc.Core.Internal } } - private async Task StartGetMetadata(AuthInterceptorContext context, IntPtr callbackPtr, IntPtr userDataPtr) + private async Task GetMetadataAsync(AuthInterceptorContext context, IntPtr callbackPtr, IntPtr userDataPtr) { try { diff --git a/src/csharp/Grpc.Core/Internal/UnmanagedLibrary.cs b/src/csharp/Grpc.Core/Internal/UnmanagedLibrary.cs index 31e1402849..1553bdd687 100644 --- a/src/csharp/Grpc.Core/Internal/UnmanagedLibrary.cs +++ b/src/csharp/Grpc.Core/Internal/UnmanagedLibrary.cs @@ -134,7 +134,11 @@ namespace Grpc.Core.Internal { throw new MissingMethodException(string.Format("The native method \"{0}\" does not exist", methodName)); } - return Marshal.GetDelegateForFunctionPointer(ptr, typeof(T)) as T; +#if NETSTANDARD1_5 + return Marshal.GetDelegateForFunctionPointer<T>(ptr); // non-generic version is obsolete +#else + return Marshal.GetDelegateForFunctionPointer(ptr, typeof(T)) as T; // generic version not available in .NET45 +#endif } /// <summary> diff --git a/src/csharp/Grpc.Core/Metadata.cs b/src/csharp/Grpc.Core/Metadata.cs index 915bec146c..e686f8e398 100644 --- a/src/csharp/Grpc.Core/Metadata.cs +++ b/src/csharp/Grpc.Core/Metadata.cs @@ -95,11 +95,18 @@ namespace Grpc.Core #region IList members + + /// <summary> + /// <see cref="T:IList`1"/> + /// </summary> public int IndexOf(Metadata.Entry item) { return entries.IndexOf(item); } + /// <summary> + /// <see cref="T:IList`1"/> + /// </summary> public void Insert(int index, Metadata.Entry item) { GrpcPreconditions.CheckNotNull(item); @@ -107,12 +114,18 @@ namespace Grpc.Core entries.Insert(index, item); } + /// <summary> + /// <see cref="T:IList`1"/> + /// </summary> public void RemoveAt(int index) { CheckWriteable(); entries.RemoveAt(index); } + /// <summary> + /// <see cref="T:IList`1"/> + /// </summary> public Metadata.Entry this[int index] { get @@ -128,6 +141,9 @@ namespace Grpc.Core } } + /// <summary> + /// <see cref="T:IList`1"/> + /// </summary> public void Add(Metadata.Entry item) { GrpcPreconditions.CheckNotNull(item); @@ -135,48 +151,75 @@ namespace Grpc.Core entries.Add(item); } + /// <summary> + /// <see cref="T:IList`1"/> + /// </summary> public void Add(string key, string value) { Add(new Entry(key, value)); } + /// <summary> + /// <see cref="T:IList`1"/> + /// </summary> public void Add(string key, byte[] valueBytes) { Add(new Entry(key, valueBytes)); } + /// <summary> + /// <see cref="T:IList`1"/> + /// </summary> public void Clear() { CheckWriteable(); entries.Clear(); } + /// <summary> + /// <see cref="T:IList`1"/> + /// </summary> public bool Contains(Metadata.Entry item) { return entries.Contains(item); } + /// <summary> + /// <see cref="T:IList`1"/> + /// </summary> public void CopyTo(Metadata.Entry[] array, int arrayIndex) { entries.CopyTo(array, arrayIndex); } + /// <summary> + /// <see cref="T:IList`1"/> + /// </summary> public int Count { get { return entries.Count; } } + /// <summary> + /// <see cref="T:IList`1"/> + /// </summary> public bool IsReadOnly { get { return readOnly; } } + /// <summary> + /// <see cref="T:IList`1"/> + /// </summary> public bool Remove(Metadata.Entry item) { CheckWriteable(); return entries.Remove(item); } + /// <summary> + /// <see cref="T:IList`1"/> + /// </summary> public IEnumerator<Metadata.Entry> GetEnumerator() { return entries.GetEnumerator(); |