-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Engine: Fix several code cleanup issues #6552
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 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 |
|---|---|---|
|
|
@@ -4252,7 +4252,7 @@ protected override T GetMember<T>(object obj, string memberName) | |
| // are ignored. | ||
| if (typeof(T) == typeof(PSMemberInfo)) | ||
| { | ||
| T returnValue = PSObject.dotNetInstanceAdapter.GetDotNetMethod<T>(obj, memberName); | ||
| T returnValue = base.GetDotNetMethod<T>(obj, memberName); | ||
|
Contributor
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. Shouldn't this also be changed at line 4607? It seems like GetDotNetMethod at least should be a static method, and a static instance is not needed.
Member
Author
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. Yes, I think the use of Even with
Member
Author
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 have made the similar change to |
||
| // We only return a method if there is no property by the same name | ||
| // to match the behavior we have in GetMembers | ||
| if (returnValue != null && property == null) | ||
|
|
@@ -4263,7 +4263,7 @@ protected override T GetMember<T>(object obj, string memberName) | |
|
|
||
| if (IsTypeParameterizedProperty(typeof(T))) | ||
| { | ||
| PSParameterizedProperty parameterizedProperty = PSObject.dotNetInstanceAdapter.GetDotNetProperty<PSParameterizedProperty>(obj, memberName); | ||
| PSParameterizedProperty parameterizedProperty = base.GetDotNetProperty<PSParameterizedProperty>(obj, memberName); | ||
| // We only return a parameterized property if there is no property by the same name | ||
| // to match the behavior we have in GetMembers | ||
| if (parameterizedProperty != null && property == null) | ||
|
|
@@ -4604,7 +4604,7 @@ protected override T GetMember<T>(object obj, string memberName) | |
|
|
||
| if (typeof(T).IsAssignableFrom(typeof(PSMethod))) | ||
| { | ||
| T returnValue = PSObject.dotNetInstanceAdapter.GetDotNetMethod<T>(obj, memberName); | ||
| T returnValue = base.GetDotNetMethod<T>(obj, memberName); | ||
| // We only return a method if there is no property by the same name | ||
| // to match the behavior we have in GetMembers | ||
| if (returnValue != null && property == null) | ||
|
|
@@ -4614,7 +4614,7 @@ protected override T GetMember<T>(object obj, string memberName) | |
| } | ||
| if (IsTypeParameterizedProperty(typeof(T))) | ||
| { | ||
| PSParameterizedProperty parameterizedProperty = PSObject.dotNetInstanceAdapter.GetDotNetProperty<PSParameterizedProperty>(obj, memberName); | ||
| PSParameterizedProperty parameterizedProperty = base.GetDotNetProperty<PSParameterizedProperty>(obj, memberName); | ||
| // We only return a parameterized property if there is no property by the same name | ||
| // to match the behavior we have in GetMembers | ||
| if (parameterizedProperty != null && property == null) | ||
|
|
@@ -4644,11 +4644,11 @@ protected override PSMemberInfoInternalCollection<T> GetMembers<T>(object obj) | |
| { | ||
| DoAddAllProperties<T>(obj, returnValue); | ||
| } | ||
| PSObject.dotNetInstanceAdapter.AddAllMethods(obj, returnValue, true); | ||
| base.AddAllMethods(obj, returnValue, true); | ||
| if (IsTypeParameterizedProperty(typeof(T))) | ||
| { | ||
| var parameterizedProperties = new PSMemberInfoInternalCollection<PSParameterizedProperty>(); | ||
| PSObject.dotNetInstanceAdapter.AddAllProperties(obj, parameterizedProperties, true); | ||
| base.AddAllProperties(obj, parameterizedProperties, true); | ||
| foreach (PSParameterizedProperty parameterizedProperty in parameterizedProperties) | ||
| { | ||
| try | ||
|
|
||
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.
Do you have an example that demonstrates this is a bug?
It might be a change in behavior, e.g. if the instance was a "property only" adapter,
GetMembermight no longer return any methods whereas it would have before.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.
This type is
BaseDotNetAdapterForAdaptedObjectsand it derives fromDotNetAdapterdirectly. An instance of it won't be a "property only" adapter. It serves as the fall-back DotNet adapter for custom adapters.I may miss an aspect of your comment, could you please explain your concern a bit more?
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.
And performance shouldn't be a problem because the cache tables are static to the process, so every instance of
DotNetAdaptercan benefit from them.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.
I see, I thought this might be used by
ThirdPartyAdapteror otherPropertyOnlyAdapterimplementations, but it's the fallback adapter.After reviewing
BaseDotNetAdapterForAdaptedObjectsandPropertyOnlyAdapterand related methods, I don't understand why it exists at all.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.
I have made the similar change to
PropertyOnlyAdapter.