Skip to content

C#: Re-use asPartialModel in utility and test code. #8449

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

Closed

Conversation

michaelnebel
Copy link
Contributor

@michaelnebel michaelnebel commented Mar 15, 2022

In this PR we

  • Push the declaration of asPartialModel downwards and into DataFlowCallable to allow sharing between test code and utility code.
  • Move RelevantSummarizedCallable out of the shared flow summary implementation (it was only used by C#). This simplifies the implementation as we can reduce the height of the inheritance hierarchy.
  • Base the TargetApi for C# on DataFlowCallable (ie. only Callables with unbound declarations), which we should have done in the first place.

@michaelnebel michaelnebel marked this pull request as ready for review March 15, 2022 15:18
@michaelnebel michaelnebel requested review from a team as code owners March 15, 2022 15:18
@michaelnebel michaelnebel added the no-change-note-required This PR does not need a change note label Mar 15, 2022
}

/** Computes the first 6 columns for CSV rows. */
string asPartialModel() {
Copy link
Contributor

Choose a reason for hiding this comment

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

This predicate and isBaseCallableOrPrototype will now be public (since DataFlowCallable is), which I don't think we want. Instead it would be better to add them as top-level predicates in DataFlowPrivate.qll.

@@ -1022,46 +1022,6 @@ module Private {
}
}

/** Provides a query predicate for outputting a set of relevant flow summaries. */
Copy link
Contributor

Choose a reason for hiding this comment

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

I still think it makes sense to have here, in case other languages want to use it later.

private string isExtensible(RefType ref) {
if ref.isFinal() then result = "false" else result = "true"
}
private string isExtensible(RefType ref) {
Copy link
Contributor

Choose a reason for hiding this comment

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

These predicates should not be members of TargetApi, as that means there is a Cartesian product with the implicit this parameter.

string asPartialModel() {
result =
this.typeAsSummaryModel() + ";" //
+ isExtensible(this.bestTypeForModel()) + ";" //
Copy link
Contributor

Choose a reason for hiding this comment

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

As QL4QL says: this.isExtensible

@michaelnebel
Copy link
Contributor Author

Thank you very much for the feedback! Considering the comments, I think it is easier to start over, instead of fixing the comments here as most of the changes needs to be reverted :-)

@michaelnebel michaelnebel deleted the csharp/share-aspartialmodel branch March 16, 2022 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C# Java no-change-note-required This PR does not need a change note Ruby
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants