Skip to content

Conversation

@lzybkr
Copy link
Contributor

@lzybkr lzybkr commented Dec 15, 2017

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.

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

Choose a reason for hiding this comment

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

ResolveITypeName again check iTypeName as TypeName - can we use internal static Type ResolveTypeName(TypeName typeName, out Exception exception)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, you might have something else like a generic or array type instead of a simple type.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for clarify!
Should we test these cases too (generic or array)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

@iSazonov iSazonov merged commit 8bd5378 into PowerShell:master Jan 9, 2018
iSazonov added a commit that referenced this pull request Jan 10, 2018
@lzybkr lzybkr deleted the fix_5661 branch November 24, 2018 06:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Getting error "Unable to find type" when using IValidateSetValuesGenerator in a PowerShell module

3 participants