Skip to content
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

Crash when accessing static hidden methods from zero touch nodes #11238

Merged
merged 14 commits into from
Nov 12, 2020
15 changes: 12 additions & 3 deletions src/Engine/ProtoCore/Reflection/Mirror.cs
Original file line number Diff line number Diff line change
Expand Up @@ -361,10 +361,13 @@ public IEnumerable<StaticMirror> GetMembers()
{
// TODO: Factor out reflection functionality for both LibraryServices and Mirrors
List<StaticMirror> members = new List<StaticMirror>();
members.AddRange(this.GetConstructors().GroupBy(x => x.Name).Select(y => y.First()));
members.AddRange(this.GetFunctions().Where(m => m.IsStatic).GroupBy(x => x.Name).Select(y => y.First()));
members.AddRange(this.GetProperties().Where(m => m.IsStatic).GroupBy(x => x.Name).Select(y => y.First()));
members.AddRange(GetConstructors().GroupBy(x => x.Name).Select(y => y.First()));
members.AddRange(GetFunctions().Where(m => m.IsStatic).GroupBy(x => x.Name).Select(y => y.First()));
members.AddRange(GetProperties().Where(m => m.IsStatic).GroupBy(x => x.Name).Select(y => y.First()));

// Filter out hidden functions/properties:
// Create a set of unique function, property and constructor descriptions.
// In this case we use ToString() to get the uniques description of the members (func signature, propety names, constructor names).
pinzart90 marked this conversation as resolved.
Show resolved Hide resolved
var derivedClassMembers = new HashSet<string>();
members.ForEach(x => derivedClassMembers.Add(x.ToString()));

Expand Down Expand Up @@ -499,6 +502,9 @@ public IEnumerable<MethodMirror> GetOverloadsOnType(string methodName)
members.AddRange(this.GetConstructors().Where(x => x.MethodName == methodName));
members.AddRange(this.GetFunctions().Where(x => x.IsStatic && x.MethodName == methodName));

// Filter out hidden functions/properties:
// Create a set of unique function and constructor descriptions.
// In this case we use ToString() to get the uniques description of the members (func signature, constructor names).
var derivedClassMembers = new HashSet<string>();
members.ForEach(x => derivedClassMembers.Add(x.ToString()));
Copy link
Contributor

@aparajit-pratap aparajit-pratap Nov 11, 2020

Choose a reason for hiding this comment

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

Are you going to make the same simplification in this commit over here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

GetOverloadsOnType must show duplicate names, so I cannot apply the simplification.
The existing code will filter duplicate signatures .


Expand Down Expand Up @@ -542,6 +548,9 @@ public IEnumerable<StaticMirror> GetInstanceMembers()
members.AddRange(this.GetFunctions().Where(m => !m.IsStatic).GroupBy(x => x.Name).Select(y => y.First()));
members.AddRange(this.GetProperties().Where(m => !m.IsStatic).GroupBy(x => x.Name).Select(y => y.First()));

// Filter out hidden functions/properties:
// Create a set of unique function and property descriptions.
// In this case we use ToString() to get the uniques description of the members (func signature, propety names).
var derivedClassMembers = new HashSet<string>();
members.ForEach(x => derivedClassMembers.Add(x.ToString()));

Expand Down