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

Type.BaseClass vs base "Type" #221

Closed
michaelaird opened this issue Oct 10, 2017 · 2 comments
Closed

Type.BaseClass vs base "Type" #221

michaelaird opened this issue Oct 10, 2017 · 2 comments

Comments

@michaelaird
Copy link
Contributor

I'm trying to write some code that will iterate through Types and yield return Types. I'm running into a roadblock when I need to deal with the base class of a Type because BaseClass is a Class instead of a Type.

Is there a way to convert from a Class to a Type or would it be possible to add a property to Type for BaseType that returns a Type?

@frhagn
Copy link
Owner

frhagn commented Oct 15, 2017

Added support in Typewriter 1.15.0 for casting Class, Enum and Interface to Type e.g.

${
    string Test(Class c)
    {
        var baseType = (Type)c.BaseClass;
        return baseType?.Name;
    }
}
$Classes(FILTER)[
    $Test
]

@michaelaird
Copy link
Contributor Author

This perfectly solves my need. Thank you!

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

No branches or pull requests

2 participants