Skip to content

Commit 58513ca

Browse files
committed
C#/Java: Add model generator test examples.
1 parent 6cd548f commit 58513ca

File tree

2 files changed

+148
-0
lines changed

2 files changed

+148
-0
lines changed

csharp/ql/test/utils/modelgenerator/dataflow/Summaries.cs

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,3 +838,83 @@ public void SetProp2(string v)
838838
Prop2 = v;
839839
}
840840
}
841+
842+
public class Fanout
843+
{
844+
845+
public abstract class Base1
846+
{
847+
public abstract string GetValue();
848+
}
849+
850+
public abstract class Base2 : Base1 { }
851+
852+
public class Impl1 : Base1
853+
{
854+
public string Prop { get; set; }
855+
856+
// summary=Models;Fanout+Base1;true;GetValue;();;Argument[this];ReturnValue;taint;df-generated
857+
// contentbased-summary=Models;Fanout+Impl1;true;GetValue;();;Argument[this].Property[Models.Fanout+Impl1.Prop];ReturnValue;value;df-generated
858+
public override string GetValue()
859+
{
860+
return Prop;
861+
}
862+
}
863+
864+
public class Impl2 : Base2
865+
{
866+
public string Prop { get; set; }
867+
868+
// summary=Models;Fanout+Base1;true;GetValue;();;Argument[this];ReturnValue;taint;df-generated
869+
// contentbased-summary=Models;Fanout+Impl2;true;GetValue;();;Argument[this].Property[Models.Fanout+Impl2.Prop];ReturnValue;value;df-generated
870+
public override string GetValue()
871+
{
872+
return Prop;
873+
}
874+
}
875+
876+
public class Impl3 : Base2
877+
{
878+
public string Prop { get; set; }
879+
880+
// summary=Models;Fanout+Base1;true;GetValue;();;Argument[this];ReturnValue;taint;df-generated
881+
// contentbased-summary=Models;Fanout+Impl3;true;GetValue;();;Argument[this].Property[Models.Fanout+Impl3.Prop];ReturnValue;value;df-generated
882+
public override string GetValue()
883+
{
884+
return Prop;
885+
}
886+
}
887+
888+
public class Impl4 : Base2
889+
{
890+
public string Prop { get; set; }
891+
892+
// summary=Models;Fanout+Base1;true;GetValue;();;Argument[this];ReturnValue;taint;df-generated
893+
// contentbased-summary=Models;Fanout+Impl4;true;GetValue;();;Argument[this].Property[Models.Fanout+Impl4.Prop];ReturnValue;value;df-generated
894+
public override string GetValue()
895+
{
896+
return Prop;
897+
}
898+
}
899+
900+
// summary=Models;Fanout;false;ConcatValueOnBase1;(System.String,Models.Fanout+Base1);;Argument[0];ReturnValue;taint;df-generated
901+
// summary=Models;Fanout;false;ConcatValueOnBase1;(System.String,Models.Fanout+Base1);;Argument[1];ReturnValue;taint;df-generated
902+
// No content based summaries are expected for this method on parameter `b1`
903+
// as the fanout (number of content flows) exceeds the limit of 3.
904+
// contentbased-summary=Models;Fanout;false;ConcatValueOnBase1;(System.String,Models.Fanout+Base1);;Argument[0];ReturnValue;taint;df-generated
905+
public string ConcatValueOnBase1(string other, Base1 b1)
906+
{
907+
return other + b1.GetValue();
908+
}
909+
910+
// summary=Models;Fanout;false;ConcatValueOnBase2;(System.String,Models.Fanout+Base2);;Argument[0];ReturnValue;taint;df-generated
911+
// summary=Models;Fanout;false;ConcatValueOnBase2;(System.String,Models.Fanout+Base2);;Argument[1];ReturnValue;taint;df-generated
912+
// contentbased-summary=Models;Fanout;false;ConcatValueOnBase2;(System.String,Models.Fanout+Base2);;Argument[0];ReturnValue;taint;df-generated
913+
// contentbased-summary=Models;Fanout;false;ConcatValueOnBase2;(System.String,Models.Fanout+Base2);;Argument[1].Property[Models.Fanout+Impl2.Prop];ReturnValue;taint;df-generated
914+
// contentbased-summary=Models;Fanout;false;ConcatValueOnBase2;(System.String,Models.Fanout+Base2);;Argument[1].Property[Models.Fanout+Impl3.Prop];ReturnValue;taint;df-generated
915+
// contentbased-summary=Models;Fanout;false;ConcatValueOnBase2;(System.String,Models.Fanout+Base2);;Argument[1].Property[Models.Fanout+Impl4.Prop];ReturnValue;taint;df-generated
916+
public string ConcatValueOnBase2(string other, Base2 b2)
917+
{
918+
return other + b2.GetValue();
919+
}
920+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package p;
2+
3+
public class Fanout {
4+
public interface I1 {
5+
String getValue();
6+
}
7+
8+
public interface I2 extends I1 {}
9+
10+
public class Impl1 implements I1 {
11+
public String v;
12+
13+
// summary=p;Fanout$I1;true;getValue;();;Argument[this];ReturnValue;taint;df-generated
14+
// contentbased-summary=p;Fanout$Impl1;true;getValue;();;Argument[this].Field[p.Fanout$Impl1.v];ReturnValue;value;df-generated
15+
public String getValue() {
16+
return v;
17+
}
18+
}
19+
20+
public class Impl2 implements I2 {
21+
public String v;
22+
23+
// summary=p;Fanout$I1;true;getValue;();;Argument[this];ReturnValue;taint;df-generated
24+
// contentbased-summary=p;Fanout$Impl2;true;getValue;();;Argument[this].Field[p.Fanout$Impl2.v];ReturnValue;value;df-generated
25+
public String getValue() {
26+
return v;
27+
}
28+
}
29+
30+
public class Impl3 implements I2 {
31+
public String v;
32+
33+
// summary=p;Fanout$I1;true;getValue;();;Argument[this];ReturnValue;taint;df-generated
34+
// contentbased-summary=p;Fanout$Impl3;true;getValue;();;Argument[this].Field[p.Fanout$Impl3.v];ReturnValue;value;df-generated
35+
public String getValue() {
36+
return v;
37+
}
38+
}
39+
40+
public class Impl4 implements I2 {
41+
public String v;
42+
43+
// summary=p;Fanout$I1;true;getValue;();;Argument[this];ReturnValue;taint;df-generated
44+
// contentbased-summary=p;Fanout$Impl4;true;getValue;();;Argument[this].Field[p.Fanout$Impl4.v];ReturnValue;value;df-generated
45+
public String getValue() {
46+
return v;
47+
}
48+
}
49+
50+
// summary=p;Fanout;true;concatGetValueOnI1;(String,Fanout$I1);;Argument[0];ReturnValue;taint;df-generated
51+
// summary=p;Fanout;true;concatGetValueOnI1;(String,Fanout$I1);;Argument[1];ReturnValue;taint;df-generated
52+
// No content based summaries are expected for this method on parameter `i`
53+
// as the fanout (number of content flows) exceeds the limit of 3.
54+
// contentbased-summary=p;Fanout;true;concatGetValueOnI1;(String,Fanout$I1);;Argument[0];ReturnValue;taint;df-generated
55+
public String concatGetValueOnI1(String other, I1 i) {
56+
return other + i.getValue();
57+
}
58+
59+
// summary=p;Fanout;true;concatGetValueOnI2;(String,Fanout$I2);;Argument[0];ReturnValue;taint;df-generated
60+
// summary=p;Fanout;true;concatGetValueOnI2;(String,Fanout$I2);;Argument[1];ReturnValue;taint;df-generated
61+
// contentbased-summary=p;Fanout;true;concatGetValueOnI2;(String,Fanout$I2);;Argument[0];ReturnValue;taint;df-generated
62+
// contentbased-summary=p;Fanout;true;concatGetValueOnI2;(String,Fanout$I2);;Argument[1].Field[p.Fanout$Impl2.v];ReturnValue;taint;df-generated
63+
// contentbased-summary=p;Fanout;true;concatGetValueOnI2;(String,Fanout$I2);;Argument[1].Field[p.Fanout$Impl3.v];ReturnValue;taint;df-generated
64+
// contentbased-summary=p;Fanout;true;concatGetValueOnI2;(String,Fanout$I2);;Argument[1].Field[p.Fanout$Impl4.v];ReturnValue;taint;df-generated
65+
public String concatGetValueOnI2(String other, I2 i) {
66+
return other + i.getValue();
67+
}
68+
}

0 commit comments

Comments
 (0)