Merge pull request #8438 from jtattermusch/csharp_compiler_warnings

Fix a few C# compiler warnings
pull/8395/head
Jan Tattermusch 8 years ago committed by GitHub
commit 8834095e76
  1. 4
      src/csharp/Grpc.Auth/GoogleAuthInterceptors.cs
  2. 1
      src/csharp/Grpc.Core/DefaultCallInvoker.cs
  3. 1
      src/csharp/Grpc.Core/GrpcEnvironment.cs
  4. 2
      src/csharp/Grpc.Core/Internal/InterceptingCallInvoker.cs
  5. 7
      src/csharp/Grpc.Core/Internal/NativeMetadataCredentialsPlugin.cs
  6. 6
      src/csharp/Grpc.Core/Internal/UnmanagedLibrary.cs
  7. 43
      src/csharp/Grpc.Core/Metadata.cs

@ -33,6 +33,7 @@
using System; using System;
using System.Threading; using System.Threading;
using System.Threading.Tasks;
using Google.Apis.Auth.OAuth2; using Google.Apis.Auth.OAuth2;
using Grpc.Core; using Grpc.Core;
@ -72,9 +73,10 @@ namespace Grpc.Auth
public static AsyncAuthInterceptor FromAccessToken(string accessToken) public static AsyncAuthInterceptor FromAccessToken(string accessToken)
{ {
GrpcPreconditions.CheckNotNull(accessToken); GrpcPreconditions.CheckNotNull(accessToken);
return new AsyncAuthInterceptor(async (context, metadata) => return new AsyncAuthInterceptor((context, metadata) =>
{ {
metadata.Add(CreateBearerTokenHeader(accessToken)); metadata.Add(CreateBearerTokenHeader(accessToken));
return Task.FromResult<object>(null);
}); });
} }

@ -102,6 +102,7 @@ namespace Grpc.Core
return Calls.AsyncDuplexStreamingCall(call); 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) protected virtual CallInvocationDetails<TRequest, TResponse> CreateCall<TRequest, TResponse>(Method<TRequest, TResponse> method, string host, CallOptions options)
where TRequest : class where TRequest : class
where TResponse : class where TResponse : class

@ -59,7 +59,6 @@ namespace Grpc.Core
static ILogger logger = new NullLogger(); static ILogger logger = new NullLogger();
readonly object myLock = new object();
readonly GrpcThreadPool threadPool; readonly GrpcThreadPool threadPool;
readonly DebugStats debugStats = new DebugStats(); readonly DebugStats debugStats = new DebugStats();
readonly AtomicCounter cqPickerCounter = new AtomicCounter(); readonly AtomicCounter cqPickerCounter = new AtomicCounter();

@ -48,7 +48,7 @@ namespace Grpc.Core.Internal
readonly Func<CallOptions, CallOptions> callOptionsInterceptor; readonly Func<CallOptions, CallOptions> callOptionsInterceptor;
/// <summary> /// <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> /// </summary>
public InterceptingCallInvoker(CallInvoker callInvoker, public InterceptingCallInvoker(CallInvoker callInvoker,
Func<string, string> hostInterceptor = null, Func<string, string> hostInterceptor = null,

@ -78,7 +78,10 @@ namespace Grpc.Core.Internal
{ {
var context = new AuthInterceptorContext(Marshal.PtrToStringAnsi(serviceUrlPtr), var context = new AuthInterceptorContext(Marshal.PtrToStringAnsi(serviceUrlPtr),
Marshal.PtrToStringAnsi(methodNamePtr)); 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) 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 try
{ {

@ -134,7 +134,11 @@ namespace Grpc.Core.Internal
{ {
throw new MissingMethodException(string.Format("The native method \"{0}\" does not exist", methodName)); 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> /// <summary>

@ -95,11 +95,18 @@ namespace Grpc.Core
#region IList members #region IList members
/// <summary>
/// <see cref="T:IList`1"/>
/// </summary>
public int IndexOf(Metadata.Entry item) public int IndexOf(Metadata.Entry item)
{ {
return entries.IndexOf(item); return entries.IndexOf(item);
} }
/// <summary>
/// <see cref="T:IList`1"/>
/// </summary>
public void Insert(int index, Metadata.Entry item) public void Insert(int index, Metadata.Entry item)
{ {
GrpcPreconditions.CheckNotNull(item); GrpcPreconditions.CheckNotNull(item);
@ -107,12 +114,18 @@ namespace Grpc.Core
entries.Insert(index, item); entries.Insert(index, item);
} }
/// <summary>
/// <see cref="T:IList`1"/>
/// </summary>
public void RemoveAt(int index) public void RemoveAt(int index)
{ {
CheckWriteable(); CheckWriteable();
entries.RemoveAt(index); entries.RemoveAt(index);
} }
/// <summary>
/// <see cref="T:IList`1"/>
/// </summary>
public Metadata.Entry this[int index] public Metadata.Entry this[int index]
{ {
get get
@ -128,6 +141,9 @@ namespace Grpc.Core
} }
} }
/// <summary>
/// <see cref="T:IList`1"/>
/// </summary>
public void Add(Metadata.Entry item) public void Add(Metadata.Entry item)
{ {
GrpcPreconditions.CheckNotNull(item); GrpcPreconditions.CheckNotNull(item);
@ -135,48 +151,75 @@ namespace Grpc.Core
entries.Add(item); entries.Add(item);
} }
/// <summary>
/// <see cref="T:IList`1"/>
/// </summary>
public void Add(string key, string value) public void Add(string key, string value)
{ {
Add(new Entry(key, value)); Add(new Entry(key, value));
} }
/// <summary>
/// <see cref="T:IList`1"/>
/// </summary>
public void Add(string key, byte[] valueBytes) public void Add(string key, byte[] valueBytes)
{ {
Add(new Entry(key, valueBytes)); Add(new Entry(key, valueBytes));
} }
/// <summary>
/// <see cref="T:IList`1"/>
/// </summary>
public void Clear() public void Clear()
{ {
CheckWriteable(); CheckWriteable();
entries.Clear(); entries.Clear();
} }
/// <summary>
/// <see cref="T:IList`1"/>
/// </summary>
public bool Contains(Metadata.Entry item) public bool Contains(Metadata.Entry item)
{ {
return entries.Contains(item); return entries.Contains(item);
} }
/// <summary>
/// <see cref="T:IList`1"/>
/// </summary>
public void CopyTo(Metadata.Entry[] array, int arrayIndex) public void CopyTo(Metadata.Entry[] array, int arrayIndex)
{ {
entries.CopyTo(array, arrayIndex); entries.CopyTo(array, arrayIndex);
} }
/// <summary>
/// <see cref="T:IList`1"/>
/// </summary>
public int Count public int Count
{ {
get { return entries.Count; } get { return entries.Count; }
} }
/// <summary>
/// <see cref="T:IList`1"/>
/// </summary>
public bool IsReadOnly public bool IsReadOnly
{ {
get { return readOnly; } get { return readOnly; }
} }
/// <summary>
/// <see cref="T:IList`1"/>
/// </summary>
public bool Remove(Metadata.Entry item) public bool Remove(Metadata.Entry item)
{ {
CheckWriteable(); CheckWriteable();
return entries.Remove(item); return entries.Remove(item);
} }
/// <summary>
/// <see cref="T:IList`1"/>
/// </summary>
public IEnumerator<Metadata.Entry> GetEnumerator() public IEnumerator<Metadata.Entry> GetEnumerator()
{ {
return entries.GetEnumerator(); return entries.GetEnumerator();

Loading…
Cancel
Save