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

optimize InterfaceBinderAnalyzer #936

Merged
merged 1 commit into from
Nov 20, 2023

Conversation

omsmith
Copy link
Contributor

@omsmith omsmith commented Nov 20, 2023

With ImmutabilityAnalyzer as reference (given run variability):

Analyzer Before After
ImmutabilityAnalyzer 11.804s 11.681s
InterfaceBinderAnalyzer 5.898s 342ms

Comment on lines -26 to +47
var type = typeof( InterfaceBinder< /* InterfaceBinder_InterfacesOnly(ClassDto) */ ClassDto /**/ > );
// This used to be considered an error; however, the updated version of the analyzer
// only looks at member accesses rather than generic type names to be less expensive
_ = typeof( InterfaceBinder<ClassDto> );

_ = /* InterfaceBinder_InterfacesOnly(ClassDto) */ InterfaceBinder<ClassDto>.AllFields /**/;
_ = /* InterfaceBinder_InterfacesOnly(ClassDto) */ InterfaceBinder<ClassDto>.CreateAllFields() /**/;
_ = /* InterfaceBinder_InterfacesOnly(ClassDto) */ InterfaceBinder<ClassDto>.MatchedFields /**/;
_ = /* InterfaceBinder_InterfacesOnly(ClassDto) */ InterfaceBinder<ClassDto>.CreateMathedFields() /**/;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Erroring on a different usage (now just public API usage), but much less work to do so. I don't expect simply referencing the type InterfaceBinder<ClassDto> would really lead to any issues (outside of reflection, but that's a general hole regardless).


public void TooManyGenericTypeArguments() {
var type = typeof( Action<int, int> );
_ = /* InterfaceBinder_InterfacesOnly(Wacky) */ InterfaceBinder<Wacky>.AllFields /**/;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wacky is TypeKind.ErrorType, so still works

@omsmith omsmith merged commit e344a88 into main Nov 20, 2023
1 check passed
@omsmith omsmith deleted the omsmith/interfacebinder-optimizations branch November 20, 2023 20:48
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.

2 participants