8000 Domain reload test cases fixes by BadSingleton · Pull Request #1287 · pythonnet/pythonnet · GitHub
[go: up one dir, main page]

Skip to content

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

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
fc7da1d
Adds test cases for member changes during a domain reload
BadSingleton Nov 9, 2020
72fafdd
!fixup add the project to the solution files
BadSingleton Nov 9, 2020
20861b2
Add more test cases
BadSingleton Nov 18, 2020
2253ef3
Merge remote-tracking branch 'upstream/master' into domain-reload-tes…
BadSingleton Nov 18, 2020
635edac
Make the tests run as netcoreapp
BadSingleton Nov 19, 2020
0ee931e
Remove stray colon
BadSingleton Nov 19, 2020
3dad96e
Rework the serialization of reflected types
BadSingleton Nov 19, 2020
90a81f3
Call PyType_Modified after modifying the type
BadSingleton Nov 20, 2020
10276f1
Some code review changes
BadSingleton Nov 20, 2020
4d0e2ce
fixup! Some code review changes
BadSingleton Nov 23, 2020
02fa245
Remove hungarian notation from Maybe* types
BadSingleton Nov 23, 2020
91c881c
Check the type of the exception before ignoring it
BadSingleton Nov 23, 2020
284e8e1
Check for validity, don't throw
BadSingleton Nov 23, 2020
fe96781
Refactor the member binding logic of ClassManager
BadSingleton Nov 23, 2020
6ff9e0b
Include info about why deserialization failed in Maybe*
BadSingleton Nov 23, 2020
4d2d05b
improve deserialization resolution of ref, out and in parameters
BadSingleton Nov 24, 2020
5f061bc
Clean up the project and solution files
BadSingleton Nov 26, 2020
3adc559
Merge branch 'master' into domain-reload-test-cases
BadSingleton Nov 26, 2020
e8543cf
Rework the serialization of reflected types
BadSingleton Nov 19, 2020
61b0d8c
Call PyType_Modified after modifying the type
BadSingleton Nov 20, 2020
c8bacf3
Some code review changes
BadSingleton Nov 20, 2020
cde5c23
fixup! Some code review changes
BadSingleton Nov 23, 2020
a956773
Remove hungarian notation from Maybe* types
BadSingleton Nov 23, 2020
ee3b391
Check the type of the exception before ignoring it
BadSingleton Nov 23, 2020
9b4d5f9
Check for validity, don't throw
BadSingleton Nov 23, 2020
a2f3294
Refactor the member binding logic of ClassManager
BadSingleton Nov 23, 2020
46dcb9d
Include info about why deserialization failed in Maybe*
BadSingleton Nov 23, 2020
10116bb
improve deserialization resolution of ref, out and in parameters
BadSingleton Nov 24, 2020
102054e
!fixup leftover error from the rebase
BadSingleton Nov 26, 2020
329de5d
Add fixes and test for nested classes
BadSingleton Nov 27, 2020
f97262b
Code review fixes
BadSingleton Dec 2, 2020
ceb3fab
Merge branch 'master' into domain-reload-test-cases-fixes
BadSingleton Dec 2, 2020
2d6ae4c
fixup! Merge branch 'master' into domain-reload-test-cases-fixes
BadSingleton Dec 2, 2020
16a39a6
fixup! Code review fixes
BadSingleton Dec 2, 2020
ace340d
Fix build failures on non-windows
BadSingleton Dec 8, 2020
78a8088
fixup! Fix build failures on non-windows
BadSingleton Dec 8, 2020
3232f79
Merge remote-tracking branch 'origin/domain-reload-test-cases-fixes' …
BadSingleton Dec 8, 2020
87287a5
Merge branch 'master' into domain-reload-test-cases-fixes
BadSingleton Dec 8, 2020
44b4800
Merge branch 'master' into domain-reload-test-cases-fixes
BadSingleton Dec 10, 2020
79516f1
Code review fixes
BadSingleton Dec 10, 2020
421f665
Merge remote-tracking branch 'upstream/master' into domain-reload-tes…
BadSingleton Dec 10, 2020
5e4c976
(WIP) rework project structure
BadSingleton Dec 11, 2020
9d1991a
Merge remote-tracking branch 'upstream/master' into domain-reload-tes…
BadSingleton Dec 14, 2020
bcf0cd6
Rework the projects file structure
BadSingleton Dec 14, 2020
73e5a6b
Check teh return value of PyDict_DelItemString
BadSingleton Dec 14, 2020
510a7ae
netstandard.dll is a Facade Library
BadSingleton Dec 16, 2020
21eb14c
Remove TestClassReference
BadSingleton Dec 17, 2020
59e81e2
Test runner docs fixes
BadSingleton Dec 17, 2020
1383b5a
Skip the domain reload tests on macos
BadSingleton Dec 17, 2020
fbc06ef
fixup! Skip the domain reload tests on macos
BadSingleton Dec 17, 2020
b3e86da
Update ISSUE_TEMPLATE.md
filmor Dec 17, 2020
0b027c6
refactoring in CreateSubType
lostmsu Dec 17, 2020
b4533c4
allocate space for GCHandle in instances of CLR Metatype (which are t…
lostmsu Dec 18, 2020
0a3f044
classderived: handle tp_dealloc called after tp_clear
lostmsu Dec 18, 2020
639236a
a few extra assertions
lostmsu Dec 18, 2020
3069285
fixed crash in finalizer of CLR types defined in Python, that survive…
lostmsu Dec 18, 2020
5c14aad
Merge branch 'master' into domain-reload-test-cases-fixes
BadSingleton Dec 18, 2020
00c19d5
Merge branch 'master' into domain-reload-test-cases-fixes
BadSingleton Jan 4, 2021
833e836
Fix break introduced by merge
BadSingleton Jan 4, 2021
62ae107
Code review fixes
BadSingleton Jan 4, 2021
eedbae5
Merge remote-tracking branch 'upstream/master' into domain-reload-tes…
BadSingleton Jan 5, 2021
73f39bc
Add the PID of the test runner
BadSingleton Jan 6, 2021
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
Prev Previous commit
Next Next commit
Remove hungarian notation from Maybe* types
  • Loading branch information
BadSingleton committed Nov 23, 2020
commit 02fa245eed021c36ab211d7969766d5c871b2c5d
40 changes: 20 additions & 20 deletions src/runtime/StateSerialization/MaybeMemberInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand All @@ -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;}}
8000 Copy link
Member

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.

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();
Copy link
Contributor

Choose a reason for hiding this comment

The 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.
You only need to deserialize the name if info failed to deserialize for whatever reason.

Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

debugging is easier if you always have the name.

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)
{
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);
}
}
}
Expand Down
52 changes: 26 additions & 26 deletions src/runtime/StateSerialization/MaybeMethodBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand All @@ -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;}}
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;
Copy link
Contributor

Choose a reason for hiding this comment

The 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);
Copy link
Member

Choose a reason for hiding this comment

The 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 const.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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[]));
}
}
}
Expand Down
30 changes: 15 additions & 15 deletions src/runtime/StateSerialization/MaybeType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,52 +11,52 @@ internal struct MaybeType : ISerializable
{
public static implicit operator MaybeType (Type ob) => new MaybeType(ob);

string m_name;
Type m_type;
string name;
Type type;

public string DeletedMessage
{
get
{
return $"The .NET Type {m_name} no longer exists";
return $"The .NET Type {name} no longer exists";
}
}

public Type Value
{
get
{
if (m_type == null)
if (type == null)
{
throw new SerializationException(DeletedMessage);
}
return m_type;
return type;
}
}

public string Name {get{return m_name;}}
public bool Valid => m_type != null;
public string Name {get{return name;}}
public bool Valid => type != null;

public override string ToString()
{
return (m_type != null ? m_type.ToString() : $"missing type: {m_name}");
return (type != null ? type.ToString() : $"missing type: {name}");
}

public MaybeType(Type tp)
{
m_type = tp;
m_name = tp.AssemblyQualifiedName;
type = tp;
name = tp.AssemblyQualifiedName;
}

private MaybeType(SerializationInfo info, StreamingContext context)
private MaybeType(SerializationInfo serializationInfo, StreamingContext context)
{
m_name = (string)info.GetValue("n", typeof(string));
m_type = Type.GetType(m_name, throwOnError:false);
name = (string)serializationInfo.GetValue("n", typeof(string));
type = Type.GetType(name, throwOnError:false);
}

public void GetObjectData(SerializationInfo info, StreamingContext context)
public void GetObjectData(SerializationInfo serializationInfo, StreamingContext context)
{
info.AddValue("n", m_name);
serializationInfo.AddValue("n", name);
}
}
}
0