-
Notifications
You must be signed in to change notification settings - Fork 54
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
Unix sockets support #499
base: master
Are you sure you want to change the base?
Unix sockets support #499
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -148,7 +148,8 @@ private object ActivateRd(Type type) | |
object instance; | ||
try | ||
{ | ||
instance = Activator.CreateInstance(implementingType); | ||
instance = Activator.CreateInstance(implementingType) | ||
?? throw new InvalidOperationException($"Unable to create instance of: {implementingType.ToString(true)}"); | ||
Comment on lines
+151
to
+152
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (MInor) Sorry, why this change? It is not practical to expect |
||
} | ||
catch (MissingMethodException e) | ||
{ | ||
|
@@ -451,10 +452,10 @@ public static string GetTypeName(Type type) | |
{ | ||
var rpcInterface = ReflectionSerializerVerifier.GetRpcInterface(type.GetTypeInfo()); | ||
if (rpcInterface != null) | ||
return rpcInterface.FullName; | ||
return rpcInterface.FullName!; | ||
} | ||
|
||
return typename; | ||
return typename!; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -148,7 +148,10 @@ bool IsValidArray() | |
if (!typeInfo.IsArray) return false; | ||
if (typeInfo.GetArrayRank() != 1) return false; | ||
|
||
var arrayType = typeInfo.GetElementType().GetTypeInfo(); | ||
var elementType = typeInfo.GetElementType(); | ||
if (elementType == null) return false; | ||
Comment on lines
+151
to
+152
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should never be |
||
|
||
var arrayType = elementType.GetTypeInfo(); | ||
return IsFieldType(arrayType, false); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,13 +68,13 @@ internal static FieldInfo[] GetBindableFields(TypeInfo typeInfo) | |
return list.ToArray(); | ||
} | ||
|
||
private static IEnumerable<FieldInfo> GetFields(Type type, Type baseType) | ||
private static IEnumerable<FieldInfo> GetFields(Type? type, Type baseType) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Huh, should |
||
{ | ||
foreach (var field in type.GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public)) | ||
foreach (var field in type?.GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public) ?? Array.Empty<FieldInfo>()) | ||
yield return field; | ||
|
||
// private fields only being returned for the current type | ||
while ((type = type.BaseType) != baseType && type != null) | ||
while ((type = type?.BaseType) != baseType && type != null) | ||
{ | ||
// but protected fields are returned in first step | ||
foreach (var baseField in type.GetFields(BindingFlags.Instance | BindingFlags.NonPublic)) | ||
|
@@ -85,7 +85,7 @@ private static IEnumerable<FieldInfo> GetFields(Type type, Type baseType) | |
|
||
internal static SerializerPair ConvertPair(SerializerPair serializers, Type desiredType) | ||
{ | ||
return (SerializerPair)ourConvertSerializerPair.MakeGenericMethod(serializers.Writer.GetType().GetGenericArguments()[0], desiredType).Invoke(null, new object[] { serializers }); | ||
return (SerializerPair)ourConvertSerializerPair.MakeGenericMethod(serializers.Writer.GetType().GetGenericArguments()[0], desiredType).Invoke(null, new object[] { serializers })!; | ||
} | ||
|
||
private static readonly MethodInfo ourConvertSerializerPair = typeof(SerializerReflectionUtil).GetTypeInfo().GetMethod(nameof(ConvertPairGeneric), BindingFlags.Static | BindingFlags.NonPublic)!; | ||
|
@@ -113,15 +113,15 @@ internal static CtxReadDelegate<TOut> ConvertReader<TOut>(object reader) | |
|
||
var genericTypedRead = ourConvertTypedCtxRead.MakeGenericMethod(reader.GetType().GetGenericArguments()[0], typeof(object)); | ||
var result = genericTypedRead.Invoke(null, new[] { reader }); | ||
return (CtxReadDelegate<TOut>)result; | ||
return (CtxReadDelegate<TOut>)result!; | ||
} | ||
|
||
internal static CtxWriteDelegate<TOut> ConvertWriter<TOut>(object writer) | ||
{ | ||
if (writer is CtxWriteDelegate<TOut> objWriter) | ||
return objWriter; | ||
|
||
return (CtxWriteDelegate<TOut>)ourConvertTypedCtxWrite.MakeGenericMethod(writer.GetType().GetGenericArguments()[0], typeof(TOut)).Invoke(null, new[] { writer }); | ||
return (CtxWriteDelegate<TOut>)ourConvertTypedCtxWrite.MakeGenericMethod(writer.GetType().GetGenericArguments()[0], typeof(TOut)).Invoke(null, new[] { writer })!; | ||
} | ||
|
||
private static readonly MethodInfo ourConvertTypedCtxRead = typeof(SerializerReflectionUtil).GetTypeInfo().GetMethod(nameof(CtxReadTypedToObject), BindingFlags.Static | BindingFlags.NonPublic)!; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using System.IO; | ||
using System.Net; | ||
using System.Net.Sockets; | ||
|
||
namespace JetBrains.Rd.Impl; | ||
|
||
public class EndPointWrapper | ||
{ | ||
public EndPoint EndPointImpl { get; } | ||
public IPAddress? LocalAddress { get; private set; } | ||
public int? LocalPort { get; private set; } | ||
public string? LocalPath { get; private set; } | ||
public AddressFamily AddressFamily { get; private set; } | ||
public SocketType SocketType { get; private set; } | ||
public ProtocolType ProtocolType { get; private set; } | ||
|
||
private EndPointWrapper(EndPoint endPoint) | ||
{ | ||
EndPointImpl = endPoint; | ||
} | ||
|
||
public static EndPointWrapper CreateIpEndPoint(IPAddress? address = null, int? port = null) | ||
{ | ||
var address1 = address ?? IPAddress.Loopback; | ||
var port1 = port ?? 0; | ||
return new EndPointWrapper(new IPEndPoint(address1, port1)) | ||
{ | ||
AddressFamily = AddressFamily.InterNetwork, | ||
SocketType = SocketType.Stream, | ||
ProtocolType = ProtocolType.Tcp, | ||
LocalAddress = address1, | ||
LocalPort = port1, | ||
LocalPath = null, | ||
}; | ||
} | ||
|
||
public static EndPointWrapper CreateUnixEndPoint(string? path = null) | ||
{ | ||
var path1 = path ?? Path.GetTempFileName(); | ||
return new EndPointWrapper(new UnixDomainSocketEndPoint(path1)) { | ||
AddressFamily = AddressFamily.Unix, | ||
SocketType = SocketType.Stream, | ||
ProtocolType = ProtocolType.Unspecified, | ||
LocalAddress = null, | ||
LocalPort = null, | ||
LocalPath = path1, | ||
}; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before merging, we'll have to restore the compatibility with the older frameworks.