Fix ValidateSet with generator in a module#5702
Merged
iSazonov merged 1 commit intoPowerShell:masterfrom Jan 9, 2018
Merged
Conversation
The symbol resolver was properly resolving the type to the class definition, but that resolution was ignored at runtime because we used the string instead of the ITypeName - the ITypeName kept the reference to the class definition. Fix PowerShell#5661
iSazonov
reviewed
Dec 16, 2017
| if (ast.PositionalArguments.Count == 1 && ast.PositionalArguments[0] is TypeExpressionAst generatorTypeAst) | ||
| { | ||
| if (TypeResolver.TryResolveType(generatorTypeAst.TypeName.FullName, out Type generatorType)) | ||
| var generatorType = TypeResolver.ResolveITypeName(generatorTypeAst.TypeName, out Exception exception); |
Collaborator
There was a problem hiding this comment.
ResolveITypeName again check iTypeName as TypeName - can we use internal static Type ResolveTypeName(TypeName typeName, out Exception exception)?
Contributor
Author
There was a problem hiding this comment.
No, you might have something else like a generic or array type instead of a simple type.
Collaborator
There was a problem hiding this comment.
Thanks for clarify!
Should we test these cases too (generic or array)?
Contributor
Author
There was a problem hiding this comment.
The ast must be fully general which explains why you must use ResolveITypeName here.
In this specific case, it is extremely unlikely anyone would ever use a generic (which should work) or an array (which should be an error), so testing has marginal usefulness.
vors
approved these changes
Dec 17, 2017
6 tasks
iSazonov
added a commit
that referenced
this pull request
Jan 10, 2018
Add a test that has been skipped in PR #5702
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Summary
The symbol resolver was properly resolving the type to the class
definition, but that resolution was ignored at runtime because we used
the string instead of the ITypeName - the ITypeName kept the reference
to the class definition.
Fix #5661
PR Checklist
Note: Please mark anything not applicable to this PR
NA.NANA[feature]if the change is significant or affectes feature testsWIP:to the beginning of the title and remove the prefix when the PR is ready.