-
Notifications
You must be signed in to change notification settings - Fork 751
Domain reload test cases fixes #1287
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
Changes from 1 commit
fc7da1d
72fafdd
20861b2
2253ef3
635edac
0ee931e
3dad96e
90a81f3
10276f1
4d0e2ce
02fa245
91c881c
284e8e1
fe96781
6ff9e0b
4d2d05b
5f061bc
3adc559
e8543cf
61b0d8c
c8bacf3
cde5c23
a956773
ee3b391
9b4d5f9
a2f3294
46dcb9d
10116bb
102054e
329de5d
f97262b
ceb3fab
2d6ae4c
16a39a6
ace340d
78a8088
3232f79
87287a5
44b4800
79516f1
421f665
5e4c976
9d1991a
bcf0cd6
73e5a6b
510a7ae
21eb14c
59e81e2
1383b5a
fbc06ef
b3e86da
0b027c6
b4533c4
0a3f044
639236a
3069285
5c14aad
00c19d5
833e836
62ae107
eedbae5
73f39bc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,8 +11,8 @@ internal struct MaybeMemberInfo<T> : ISerializable where T: MemberInfo | |
{ | ||
public static implicit operator MaybeMemberInfo<T> (T ob) => new MaybeMemberInfo<T>(ob); | ||
|
||
string m_name; | ||
MemberInfo m_info; | ||
string name; | ||
MemberInfo info; | ||
|
||
// As seen in ClassManager.GetClassInfo | ||
const BindingFlags k_flags = BindingFlags.Static | | ||
|
@@ -23,62 +23,62 @@ public string DeletedMessage | |
{ | ||
get | ||
{ | ||
return $"The .NET {typeof(T)} {m_name} no longer exists"; | ||
return $"The .NET {typeof(T)} {name} no longer exists"; | ||
} | ||
} | ||
|
||
public T Value | ||
{ | ||
get | ||
{ | ||
if (m_info == null) | ||
if (info == null) | ||
{ | ||
throw new SerializationException(DeletedMessage); | ||
} | ||
return (T)m_info; | ||
return (T)info; | ||
} | ||
} | ||
|
||
public string Name {get{return m_name;}} | ||
public bool Valid => m_info != null; | ||
public string Name {get{return name;}} | ||
public bool Valid => info != null; | ||
|
||
public override string ToString() | ||
{ | ||
return (m_info != null ? m_info.ToString() : $"missing type: {m_name}"); | ||
return (info != null ? info.ToString() : $"missing type: {name}"); | ||
} | ||
|
||
public MaybeMemberInfo(T fi) | ||
{ | ||
m_info = fi; | ||
m_name = m_info?.ToString(); | ||
info = fi; | ||
name = info?.ToString(); | ||
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. Name isn't really required now. You only need it if info is null. You need to always serialize the name; if info is set, then serialize info.ToString else serialize name. 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. Maybe it doesn't matter, since the memory savings aren't huge, and debugging is easier if you always have the name. 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.
That's why I always have it |
||
} | ||
|
||
internal MaybeMemberInfo(SerializationInfo info, StreamingContext context) | ||
internal MaybeMemberInfo(SerializationInfo serializationInfo, StreamingContext context) | ||
{ | ||
// Assumption: name is always stored in "s" | ||
m_name = info.GetString("s"); | ||
m_info = null; | ||
name = serializationInfo.GetString("s"); | ||
info = null; | ||
try | ||
{ | ||
var tp = Type.GetType(info.GetString("t")); | ||
var tp = Type.GetType(serializationInfo.GetString("t")); | ||
if (tp != null) | ||
lostmsu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
var field_name = info.GetString("f"); | ||
m_info = tp.GetField(field_name, k_flags); | ||
var field_name = serializationInfo.GetString("f"); | ||
info = tp.GetField(field_name, k_flags); | ||
} | ||
} | ||
catch | ||
{ | ||
} | ||
} | ||
|
||
public void GetObjectData(SerializationInfo info, StreamingContext context) | ||
public void GetObjectData(SerializationInfo serializationInfo, StreamingContext context) | ||
{ | ||
info.AddValue("s", m_name); | ||
serializationInfo.AddValue("s", name); | ||
if (Valid) | ||
{ | ||
info.AddValue("f", m_info.Name); | ||
info.AddValue("t", m_info.ReflectedType.AssemblyQualifiedName); | ||
serializationInfo.AddValue("f", info.Name); | ||
serializationInfo.AddValue("t", info.ReflectedType.AssemblyQualifiedName); | ||
} | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,8 +11,8 @@ internal struct MaybeMethodBase<T> : ISerializable where T: MethodBase | |
{ | ||
public static implicit operator MaybeMethodBase<T> (T ob) => new MaybeMethodBase<T>(ob); | ||
|
||
string m_name; | ||
MethodBase m_info; | ||
string name; | ||
MethodBase info; | ||
// As seen in ClassManager.GetClassInfo | ||
const BindingFlags k_flags = BindingFlags.Static | | ||
BindingFlags.Instance | | ||
|
@@ -22,72 +22,72 @@ public T Value | |
{ | ||
get | ||
{ | ||
if (m_info == null) | ||
if (info == null) | ||
{ | ||
throw new SerializationException($"The .NET {typeof(T)} {m_name} no longer exists"); | ||
throw new SerializationException($"The .NET {typeof(T)} {name} no longer exists"); | ||
} | ||
return (T)m_info; | ||
return (T)info; | ||
} | ||
} | ||
|
||
public T UnsafeValue { get { return (T)m_info; } } | ||
public string Name {get{return m_name;}} | ||
public bool Valid => m_info != null; | ||
public T UnsafeValue { get { return (T)info; } } | ||
public string Name {get{return name;}} | ||
lostmsu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
public bool Valid => info != null; | ||
|
||
public override string ToString() | ||
{ | ||
return (m_info != null ? m_info.ToString() : $"missing method info: {m_name}"); | ||
return (info != null ? info.ToString() : $"missing method info: {name}"); | ||
} | ||
|
||
public MaybeMethodBase(T mi) | ||
{ | ||
m_info = mi; | ||
m_name = mi?.ToString(); | ||
info = mi; | ||
name = mi?.ToString(); | ||
} | ||
|
||
internal MaybeMethodBase(SerializationInfo info, StreamingContext context) | ||
internal MaybeMethodBase(SerializationInfo serializationInfo, StreamingContext context) | ||
{ | ||
m_name = info.GetString("s"); | ||
m_info = null; | ||
name = serializationInfo.GetString("s"); | ||
info = null; | ||
try | ||
{ | ||
// Retrive the reflected type of the method; | ||
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. *retrieve |
||
var tp = Type.GetType(info.GetString("t")); | ||
var tp = Type.GetType(serializationInfo.GetString("t")); | ||
// Get the method's parameters types | ||
var field_name = info.GetString("f"); | ||
var param = (string[])info.GetValue("p", typeof(string[])); | ||
var field_name = serializationInfo.GetString("f"); | ||
var param = (string[])serializationInfo.GetValue("p", typeof(string[])); | ||
Type[] types = new Type[param.Length]; | ||
for (int i = 0; i < param.Length; i++) | ||
{ | ||
types[i] = Type.GetType(param[i]); | ||
} | ||
// Try to get the method | ||
m_info = tp.GetMethod(field_name, k_flags, binder:null, types:types, modifiers:null); | ||
info = tp.GetMethod(field_name, k_flags, binder:null, types:types, modifiers:null); | ||
// Try again, may be a constructor | ||
if (m_info == null && m_name.Contains(".ctor&quo F438 t;)) | ||
if (info == null && name.Contains(".ctor")) | ||
{ | ||
m_info = tp.GetConstructor(k_flags, binder:null, types:types, modifiers:null); | ||
info = tp.GetConstructor(k_flags, binder:null, types:types, modifiers:null); | ||
} | ||
} | ||
catch | ||
{ | ||
} | ||
} | ||
|
||
public void GetObjectData(SerializationInfo info, StreamingContext context) | ||
public void GetObjectData(SerializationInfo serializationInfo, StreamingContext context) | ||
{ | ||
info.AddValue("s", m_name); | ||
serializationInfo.AddValue("s", name); | ||
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. I'd love to use proper names instead of just "s" here. NIT: At very least have a 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. Constants would be better. Full names would just make the serialization stream bigger. |
||
if (Valid) | ||
{ | ||
info.AddValue("f", m_info.Name); | ||
info.AddValue("t", m_info.ReflectedType.AssemblyQualifiedName); | ||
var p = m_info.GetParameters(); | ||
serializationInfo.AddValue("f", info.Name); | ||
serializationInfo.AddValue("t", info.ReflectedType.AssemblyQualifiedName); | ||
var p = info.GetParameters(); | ||
string[] types = new string[p.Length]; | ||
for (int i = 0; i < p.Length; i++) | ||
{ | ||
types[i] = p[i].ParameterType.AssemblyQualifiedName; | ||
} | ||
info.AddValue("p", types, typeof(string[])); | ||
serializationInfo.AddValue("p", types, typeof(string[])); | ||
} | ||
} | ||
} | ||
|
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.
NIT:
string Name => name;
You could also use an auto property.