Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8cc4f86

Browse files
committed
C#: Only attempt to generate models for properties that does not both have a get and a set accessor.
1 parent 32595b9 commit 8cc4f86

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

csharp/ql/src/utils/modelgenerator/internal/CaptureModelsSpecific.qll

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ private predicate isHigherOrder(CS::Callable api) {
2727
)
2828
}
2929

30+
private predicate irrelevantAccessor(CS::Accessor a) {
31+
exists(CS::Property p | p = a.getDeclaration() | exists(p.getSetter()) and exists(p.getGetter()))
32+
}
33+
3034
/**
3135
* Holds if it is relevant to generate models for `api`.
3236
*/
@@ -40,7 +44,10 @@ private predicate isRelevantForModels(CS::Callable api) {
4044
not api.(CS::Constructor).isParameterless() and
4145
// Disregard all APIs that have a manual model.
4246
not api = any(FlowSummaryImpl::Public::SummarizedCallable sc | sc.applyManualModel()) and
43-
not api = any(FlowSummaryImpl::Public::NeutralSummaryCallable sc | sc.hasManualModel())
47+
not api = any(FlowSummaryImpl::Public::NeutralSummaryCallable sc | sc.hasManualModel()) and
48+
// Disregard properties that have both a get and a set accessor,
49+
// which implicitly means auto implemented properties.
50+
not irrelevantAccessor(api)
4451
}
4552

4653
/**

0 commit comments

Comments
 (0)