Skip to content

Conversation

@jtschuster
Copy link
Member

Create an enum in the shared project for well known types to simplify type checking, avoid using string comparisons when possible, and avoid dereferencing null properties in Roslyn APIs.

Copy link
Contributor

@tlakollo tlakollo left a comment

Choose a reason for hiding this comment

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

Looks good to me

Copy link
Member

@vitek-karas vitek-karas left a comment

Choose a reason for hiding this comment

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

Looks good - I'd like to employ the MetadataType as well, but that can be done in a subsequent change.

Comment on lines +364 to +365
var (@namespace, name) = type.GetNamespaceAndName ();
return tr.IsTypeOf (@namespace, name);
Copy link
Member

Choose a reason for hiding this comment

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

Cecil has a similar concept to SpecialType - it's called MetadataType and through it one can detect primitive types (and couple of other cases) faster than string compares.

For example

if ((parameters.Count == 3 && parameters[2].ParameterType.MetadataType == MetadataType.Boolean && methodParams[2].AsConstInt () != 0) ||
does a boolean check.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good to know, I'll add that in a new PR. Thanks!

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.

4 participants