diff --git a/csharp/ql/test/TestUtilities/InlineMadTest.qll b/csharp/ql/test/TestUtilities/InlineMadTest.qll new file mode 100644 index 000000000000..b614fda41db8 --- /dev/null +++ b/csharp/ql/test/TestUtilities/InlineMadTest.qll @@ -0,0 +1,18 @@ +private import csharp as Cs +private import codeql.mad.test.InlineMadTest + +private module InlineMadTestLang implements InlineMadTestLangSig { + class Callable = Cs::Callable; + + string getComment(Callable c) { + exists(Cs::CommentBlock block, Cs::Element after | after = block.getAfter() | + ( + after = c or + after = c.(Cs::Accessor).getDeclaration() + ) and + result = block.getALine() + ) + } +} + +import InlineMadTestImpl diff --git a/csharp/ql/test/utils/modelgenerator/dataflow/CaptureNeutralModels.expected b/csharp/ql/test/utils/modelgenerator/dataflow/CaptureNeutralModels.expected index c9116cb3c62c..cb6fc390349c 100644 --- a/csharp/ql/test/utils/modelgenerator/dataflow/CaptureNeutralModels.expected +++ b/csharp/ql/test/utils/modelgenerator/dataflow/CaptureNeutralModels.expected @@ -1,24 +1,2 @@ -| NoSummaries;BaseClass;M1;(System.String);summary;df-generated | -| NoSummaries;BaseClass;M2;(System.String);summary;df-generated | -| NoSummaries;CollectionFlow;ReturnSimpleTypeArray;(System.Int32[]);summary;df-generated | -| NoSummaries;CollectionFlow;ReturnSimpleTypeDictionary;(System.Collections.Generic.Dictionary);summary;df-generated | -| NoSummaries;CollectionFlow;ReturnSimpleTypeList;(System.Collections.Generic.List);summary;df-generated | -| NoSummaries;EquatableBound;Equals;(System.Object);summary;df-generated | -| NoSummaries;EquatableUnBound;Equals;(T);summary;df-generated | -| NoSummaries;SimpleTypes;M1;(System.Boolean);summary;df-generated | -| NoSummaries;SimpleTypes;M2;(System.Boolean);summary;df-generated | -| NoSummaries;SimpleTypes;M3;(System.Int32);summary;df-generated | -| NoSummaries;SimpleTypes;M4;(System.Int32);summary;df-generated | -| Sinks;NewSinks;WrapFieldResponseWriteFile;();summary;df-generated | -| Sinks;NewSinks;WrapPrivateFieldResponseWriteFile;();summary;df-generated | -| Sinks;NewSinks;WrapPrivatePropResponseWriteFile;();summary;df-generated | -| Sinks;NewSinks;WrapPropPrivateSetResponseWriteFile;();summary;df-generated | -| Sinks;NewSinks;WrapPropResponseWriteFile;();summary;df-generated | -| Sinks;NewSinks;WrapResponseWrite;(System.Object);summary;df-generated | -| Sinks;NewSinks;WrapResponseWriteFile;(System.String);summary;df-generated | -| Sources;NewSources;WrapConsoleReadKey;();summary;df-generated | -| Sources;NewSources;WrapConsoleReadLine;();summary;df-generated | -| Sources;NewSources;WrapConsoleReadLineAndProcees;(System.String);summary;df-generated | -| Summaries;EqualsGetHashCodeNoFlow;Equals;(System.Object);summary;df-generated | -| Summaries;EqualsGetHashCodeNoFlow;GetHashCode;();summary;df-generated | -| Summaries;OperatorFlow;op_Increment;(Summaries.OperatorFlow);summary;df-generated | +unexpectedModel +expectedModel diff --git a/csharp/ql/test/utils/modelgenerator/dataflow/CaptureNeutralModels.ext.yml b/csharp/ql/test/utils/modelgenerator/dataflow/CaptureNeutralModels.ext.yml index 319d0a5ac621..6d4f3f7f54a1 100644 --- a/csharp/ql/test/utils/modelgenerator/dataflow/CaptureNeutralModels.ext.yml +++ b/csharp/ql/test/utils/modelgenerator/dataflow/CaptureNeutralModels.ext.yml @@ -3,4 +3,4 @@ extensions: pack: codeql/csharp-all extensible: neutralModel data: - - [ "NoSummaries", "ManuallyModelled", "HasNeutralSummaryNoFlow", "(System.Object)", "summary", "manual"] + - [ "Models", "ManuallyModelled", "HasNeutralSummaryNoFlow", "(System.Object)", "summary", "manual"] diff --git a/csharp/ql/test/utils/modelgenerator/dataflow/CaptureNeutralModels.ql b/csharp/ql/test/utils/modelgenerator/dataflow/CaptureNeutralModels.ql new file mode 100644 index 000000000000..c9fd2c2655db --- /dev/null +++ b/csharp/ql/test/utils/modelgenerator/dataflow/CaptureNeutralModels.ql @@ -0,0 +1,11 @@ +import csharp +import utils.modelgenerator.internal.CaptureSummaryFlowQuery +import TestUtilities.InlineMadTest + +module InlineMadTestConfig implements InlineMadTestConfigSig { + string getCapturedModel(Callable c) { result = captureNoFlow(c) } + + string getKind() { result = "neutral" } +} + +import InlineMadTest diff --git a/csharp/ql/test/utils/modelgenerator/dataflow/CaptureNeutralModels.qlref b/csharp/ql/test/utils/modelgenerator/dataflow/CaptureNeutralModels.qlref deleted file mode 100644 index 851ddc0d2946..000000000000 --- a/csharp/ql/test/utils/modelgenerator/dataflow/CaptureNeutralModels.qlref +++ /dev/null @@ -1 +0,0 @@ -utils/modelgenerator/CaptureNeutralModels.ql \ No newline at end of file diff --git a/csharp/ql/test/utils/modelgenerator/dataflow/CaptureSinkModels.expected b/csharp/ql/test/utils/modelgenerator/dataflow/CaptureSinkModels.expected index 4a11cff39afe..cb6fc390349c 100644 --- a/csharp/ql/test/utils/modelgenerator/dataflow/CaptureSinkModels.expected +++ b/csharp/ql/test/utils/modelgenerator/dataflow/CaptureSinkModels.expected @@ -1,4 +1,2 @@ -| Sinks;NewSinks;false;WrapFieldResponseWriteFile;();;Argument[this];html-injection;df-generated | -| Sinks;NewSinks;false;WrapPropResponseWriteFile;();;Argument[this];html-injection;df-generated | -| Sinks;NewSinks;false;WrapResponseWrite;(System.Object);;Argument[0];html-injection;df-generated | -| Sinks;NewSinks;false;WrapResponseWriteFile;(System.String);;Argument[0];html-injection;df-generated | +unexpectedModel +expectedModel diff --git a/csharp/ql/test/utils/modelgenerator/dataflow/CaptureSinkModels.ql b/csharp/ql/test/utils/modelgenerator/dataflow/CaptureSinkModels.ql new file mode 100644 index 000000000000..55aa379ddb5d --- /dev/null +++ b/csharp/ql/test/utils/modelgenerator/dataflow/CaptureSinkModels.ql @@ -0,0 +1,11 @@ +import csharp +import utils.modelgenerator.internal.CaptureModels +import TestUtilities.InlineMadTest + +module InlineMadTestConfig implements InlineMadTestConfigSig { + string getCapturedModel(Callable c) { result = captureSink(c) } + + string getKind() { result = "sink" } +} + +import InlineMadTest diff --git a/csharp/ql/test/utils/modelgenerator/dataflow/CaptureSinkModels.qlref b/csharp/ql/test/utils/modelgenerator/dataflow/CaptureSinkModels.qlref deleted file mode 100644 index 36d2f144247f..000000000000 --- a/csharp/ql/test/utils/modelgenerator/dataflow/CaptureSinkModels.qlref +++ /dev/null @@ -1 +0,0 @@ -utils/modelgenerator/CaptureSinkModels.ql \ No newline at end of file diff --git a/csharp/ql/test/utils/modelgenerator/dataflow/CaptureSourceModels.expected b/csharp/ql/test/utils/modelgenerator/dataflow/CaptureSourceModels.expected index 96911c15d874..cb6fc390349c 100644 --- a/csharp/ql/test/utils/modelgenerator/dataflow/CaptureSourceModels.expected +++ b/csharp/ql/test/utils/modelgenerator/dataflow/CaptureSourceModels.expected @@ -1,3 +1,2 @@ -| Sources;NewSources;false;WrapConsoleReadKey;();;ReturnValue;local;df-generated | -| Sources;NewSources;false;WrapConsoleReadLine;();;ReturnValue;local;df-generated | -| Sources;NewSources;false;WrapConsoleReadLineAndProcees;(System.String);;ReturnValue;local;df-generated | +unexpectedModel +expectedModel diff --git a/csharp/ql/test/utils/modelgenerator/dataflow/CaptureSourceModels.ql b/csharp/ql/test/utils/modelgenerator/dataflow/CaptureSourceModels.ql new file mode 100644 index 000000000000..790e0754789e --- /dev/null +++ b/csharp/ql/test/utils/modelgenerator/dataflow/CaptureSourceModels.ql @@ -0,0 +1,11 @@ +import csharp +import utils.modelgenerator.internal.CaptureModels +import TestUtilities.InlineMadTest + +module InlineMadTestConfig implements InlineMadTestConfigSig { + string getCapturedModel(Callable c) { result = captureSource(c) } + + string getKind() { result = "source" } +} + +import InlineMadTest diff --git a/csharp/ql/test/utils/modelgenerator/dataflow/CaptureSourceModels.qlref b/csharp/ql/test/utils/modelgenerator/dataflow/CaptureSourceModels.qlref deleted file mode 100644 index 6bbb499fc27b..000000000000 --- a/csharp/ql/test/utils/modelgenerator/dataflow/CaptureSourceModels.qlref +++ /dev/null @@ -1 +0,0 @@ -utils/modelgenerator/CaptureSourceModels.ql \ No newline at end of file diff --git a/csharp/ql/test/utils/modelgenerator/dataflow/CaptureSummaryModels.expected b/csharp/ql/test/utils/modelgenerator/dataflow/CaptureSummaryModels.expected index 3abb07a6987e..cb6fc390349c 100644 --- a/csharp/ql/test/utils/modelgenerator/dataflow/CaptureSummaryModels.expected +++ b/csharp/ql/test/utils/modelgenerator/dataflow/CaptureSummaryModels.expected @@ -1,40 +1,2 @@ -| NoSummaries;PublicClassFlow;false;PublicReturn;(System.Object);;Argument[0];ReturnValue;taint;df-generated | -| Summaries;BaseClassFlow;true;ReturnParam;(System.Object);;Argument[0];ReturnValue;taint;df-generated | -| Summaries;BasicFlow;false;ReturnField;();;Argument[this];ReturnValue;taint;df-generated | -| Summaries;BasicFlow;false;ReturnParam0;(System.String,System.Object);;Argument[0];ReturnValue;taint;df-generated | -| Summaries;BasicFlow;false;ReturnParam1;(System.String,System.Object);;Argument[1];ReturnValue;taint;df-generated | -| Summaries;BasicFlow;false;ReturnParamMultiple;(System.Object,System.Object);;Argument[0];ReturnValue;taint;df-generated | -| Summaries;BasicFlow;false;ReturnParamMultiple;(System.Object,System.Object);;Argument[1];ReturnValue;taint;df-generated | -| Summaries;BasicFlow;false;ReturnSubstring;(System.String);;Argument[0];ReturnValue;taint;df-generated | -| Summaries;BasicFlow;false;ReturnThis;(System.Object);;Argument[this];ReturnValue;value;df-generated | -| Summaries;BasicFlow;false;SetField;(System.String);;Argument[0];Argument[this];taint;df-generated | -| Summaries;CollectionFlow;false;AddFieldToList;(System.Collections.Generic.List);;Argument[this];Argument[0].Element;taint;df-generated | -| Summaries;CollectionFlow;false;AddToList;(System.Collections.Generic.List,System.Object);;Argument[1];Argument[0].Element;taint;df-generated | -| Summaries;CollectionFlow;false;AssignFieldToArray;(System.Object[]);;Argument[this];Argument[0].Element;taint;df-generated | -| Summaries;CollectionFlow;false;AssignToArray;(System.Object,System.Object[]);;Argument[0];Argument[1].Element;taint;df-generated | -| Summaries;CollectionFlow;false;ReturnArrayElement;(System.Object[]);;Argument[0].Element;ReturnValue;taint;df-generated | -| Summaries;CollectionFlow;false;ReturnBulkTypeList;(System.Collections.Generic.List);;Argument[0].Element;ReturnValue;taint;df-generated | -| Summaries;CollectionFlow;false;ReturnComplexTypeArray;(System.String[]);;Argument[0].Element;ReturnValue;taint;df-generated | -| Summaries;CollectionFlow;false;ReturnComplexTypeDictionary;(System.Collections.Generic.Dictionary);;Argument[0].Element;ReturnValue;taint;df-generated | -| Summaries;CollectionFlow;false;ReturnFieldInAList;();;Argument[this];ReturnValue;taint;df-generated | -| Summaries;CollectionFlow;false;ReturnListElement;(System.Collections.Generic.List);;Argument[0].Element;ReturnValue;taint;df-generated | -| Summaries;CollectionFlow;false;ReturnUntypedArray;(System.Array);;Argument[0].Element;ReturnValue;taint;df-generated | -| Summaries;CollectionFlow;false;ReturnUntypedList;(System.Collections.IList);;Argument[0].Element;ReturnValue;taint;df-generated | -| Summaries;DerivedClass1Flow;false;ReturnParam1;(System.String,System.String);;Argument[1];ReturnValue;taint;df-generated | -| Summaries;DerivedClass2Flow;false;ReturnParam0;(System.String,System.Int32);;Argument[0];ReturnValue;taint;df-generated | -| Summaries;DerivedClass2Flow;false;ReturnParam;(System.Object);;Argument[0];ReturnValue;taint;df-generated | -| Summaries;EqualsGetHashCodeNoFlow;false;Equals;(System.String);;Argument[0];ReturnValue;taint;df-generated | -| Summaries;GenericFlow;false;AddFieldToGenericList;(System.Collections.Generic.List);;Argument[this];Argument[0].Element;taint;df-generated | -| Summaries;GenericFlow;false;AddToGenericList;(System.Collections.Generic.List,S);;Argument[1];Argument[0].Element;taint;df-generated | -| Summaries;GenericFlow;false;ReturnFieldInGenericList;();;Argument[this];ReturnValue;taint;df-generated | -| Summaries;GenericFlow;false;ReturnGenericElement;(System.Collections.Generic.List);;Argument[0].Element;ReturnValue;taint;df-generated | -| Summaries;GenericFlow;false;ReturnGenericField;();;Argument[this];ReturnValue;taint;df-generated | -| Summaries;GenericFlow;false;ReturnGenericParam;(S);;Argument[0];ReturnValue;taint;df-generated | -| Summaries;GenericFlow;false;SetGenericField;(T);;Argument[0];Argument[this];taint;df-generated | -| Summaries;IEnumerableFlow;false;ReturnFieldInIEnumerable;();;Argument[this];ReturnValue;taint;df-generated | -| Summaries;IEnumerableFlow;false;ReturnIEnumerable;(System.Collections.Generic.IEnumerable);;Argument[0].Element;ReturnValue;taint;df-generated | -| Summaries;IEnumerableFlow;false;ReturnIEnumerableElement;(System.Collections.Generic.IEnumerable);;Argument[0].Element;ReturnValue;taint;df-generated | -| Summaries;OperatorFlow;false;OperatorFlow;(System.Object);;Argument[0];Argument[this];taint;df-generated | -| Summaries;OperatorFlow;false;op_Addition;(Summaries.OperatorFlow,Summaries.OperatorFlow);;Argument[0];ReturnValue;taint;df-generated | -| Summaries;Properties;false;get_Prop1;();;Argument[this];ReturnValue;taint;df-generated | -| Summaries;Properties;false;set_Prop2;(System.String);;Argument[0];Argument[this];taint;df-generated | +unexpectedModel +expectedModel diff --git a/csharp/ql/test/utils/modelgenerator/dataflow/CaptureSummaryModels.ext.yml b/csharp/ql/test/utils/modelgenerator/dataflow/CaptureSummaryModels.ext.yml index 05e3b67313ce..c995ec5aa501 100644 --- a/csharp/ql/test/utils/modelgenerator/dataflow/CaptureSummaryModels.ext.yml +++ b/csharp/ql/test/utils/modelgenerator/dataflow/CaptureSummaryModels.ext.yml @@ -3,10 +3,10 @@ extensions: pack: codeql/csharp-all extensible: summaryModel data: - - [ "NoSummaries", "ManuallyModelled", False, "HasSummary", "(System.Object)", "", "Argument[0]", "ReturnValue", "value", "manual"] + - [ "Models", "ManuallyModelled", False, "HasSummary", "(System.Object)", "", "Argument[0]", "ReturnValue", "value", "manual"] - addsTo: pack: codeql/csharp-all extensible: neutralModel data: - - [ "NoSummaries", "ManuallyModelled", "HasNeutralSummary", "(System.Object)", "summary", "manual"] + - [ "Models", "ManuallyModelled", "HasNeutralSummary", "(System.Object)", "summary", "manual"] diff --git a/csharp/ql/test/utils/modelgenerator/dataflow/CaptureSummaryModels.ql b/csharp/ql/test/utils/modelgenerator/dataflow/CaptureSummaryModels.ql new file mode 100644 index 000000000000..5e4a67bcf0cb --- /dev/null +++ b/csharp/ql/test/utils/modelgenerator/dataflow/CaptureSummaryModels.ql @@ -0,0 +1,11 @@ +import csharp +import utils.modelgenerator.internal.CaptureSummaryFlowQuery +import TestUtilities.InlineMadTest + +module InlineMadTestConfig implements InlineMadTestConfigSig { + string getCapturedModel(Callable c) { result = captureFlow(c) } + + string getKind() { result = "summary" } +} + +import InlineMadTest diff --git a/csharp/ql/test/utils/modelgenerator/dataflow/CaptureSummaryModels.qlref b/csharp/ql/test/utils/modelgenerator/dataflow/CaptureSummaryModels.qlref deleted file mode 100644 index d751f3823f39..000000000000 --- a/csharp/ql/test/utils/modelgenerator/dataflow/CaptureSummaryModels.qlref +++ /dev/null @@ -1 +0,0 @@ -utils/modelgenerator/CaptureSummaryModels.ql \ No newline at end of file diff --git a/csharp/ql/test/utils/modelgenerator/dataflow/NoSummaries.cs b/csharp/ql/test/utils/modelgenerator/dataflow/NoSummaries.cs deleted file mode 100644 index 17021058485e..000000000000 --- a/csharp/ql/test/utils/modelgenerator/dataflow/NoSummaries.cs +++ /dev/null @@ -1,174 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace NoSummaries; - -// Single class with a method that produces a flow summary. -// Just to prove that, if a method like this is correctly exposed, a flow summary will be captured. -public class PublicClassFlow -{ - public object PublicReturn(object input) - { - return input; - } -} - -public sealed class PublicClassNoFlow -{ - private object PrivateReturn(object input) - { - return input; - } - - internal object InternalReturn(object input) - { - return input; - } - - private class PrivateClassNoFlow - { - public object ReturnParam(object input) - { - return input; - } - } - - private class PrivateClassNestedPublicClassNoFlow - { - public class NestedPublicClassFlow - { - public object ReturnParam(object input) - { - return input; - } - } - } -} - -public class EquatableBound : IEquatable -{ - public readonly bool tainted; - public bool Equals(object other) - { - return tainted; - } -} - -public class EquatableUnBound : IEquatable -{ - public readonly bool tainted; - public bool Equals(T? other) - { - return tainted; - } -} - -// No methods in this class will have generated flow summaries as -// simple types are used. -public class SimpleTypes -{ - public bool M1(bool b) - { - return b; - } - - public Boolean M2(Boolean b) - { - return b; - } - - public int M3(int i) - { - return i; - } - - public Int32 M4(Int32 i) - { - return i; - } -} - -public class HigherOrderParameters -{ - public string M1(string s, Func map) - { - return s; - } - - public object M2(Func map, object o) - { - return map(o); - } -} - -public abstract class BaseClass -{ - // Negative summary. - public virtual string M1(string s) - { - return ""; - } - - // Negative summary. - public abstract string M2(string s); -} - -// No methods in this class will have generated flow as -// the simple types used in the collection are not bulk data types. -public class CollectionFlow -{ - public int[] ReturnSimpleTypeArray(int[] a) - { - return a; - } - - public List ReturnSimpleTypeList(List a) - { - return a; - } - - public Dictionary ReturnSimpleTypeDictionary(Dictionary a) - { - return a; - } -} - -// A neutral model should not be created for a parameterless constructor. -public class ParameterlessConstructor -{ - public bool IsInitialized; - - public ParameterlessConstructor() - { - IsInitialized = true; - } -} - -// No models should be created, if there exist either a manual summary or neutral summary. -public class ManuallyModelled -{ - public object HasSummary(object o) - { - return o; - } - - public object HasNeutralSummary(object o) - { - return o; - } - - public object HasNeutralSummaryNoFlow(object o) - { - return null; - } -} - -public class Properties -{ - public object backingField; - public object Prop - { - get { return backingField; } - set { backingField = value; } - } -} diff --git a/csharp/ql/test/utils/modelgenerator/dataflow/Sinks.cs b/csharp/ql/test/utils/modelgenerator/dataflow/Sinks.cs index 3f89b5eae95a..5836e17df6c0 100644 --- a/csharp/ql/test/utils/modelgenerator/dataflow/Sinks.cs +++ b/csharp/ql/test/utils/modelgenerator/dataflow/Sinks.cs @@ -13,6 +13,8 @@ public class NewSinks public string PrivateSetTaintedProp { get; private set; } // New sink + // sink=Sinks;NewSinks;false;WrapResponseWrite;(System.Object);;Argument[0];html-injection;df-generated + // neutral=Sinks;NewSinks;WrapResponseWrite;(System.Object);summary;df-generated public void WrapResponseWrite(object o) { var response = new HttpResponse(); @@ -27,6 +29,8 @@ private void PrivateWrapResponseWrite(object o) } // New sink + // sink=Sinks;NewSinks;false;WrapResponseWriteFile;(System.String);;Argument[0];html-injection;df-generated + // neutral=Sinks;NewSinks;WrapResponseWriteFile;(System.String);summary;df-generated public void WrapResponseWriteFile(string s) { var response = new HttpResponse(); @@ -34,6 +38,8 @@ public void WrapResponseWriteFile(string s) } // New sink + // sink=Sinks;NewSinks;false;WrapFieldResponseWriteFile;();;Argument[this];html-injection;df-generated + // neutral=Sinks;NewSinks;WrapFieldResponseWriteFile;();summary;df-generated public void WrapFieldResponseWriteFile() { var response = new HttpResponse(); @@ -41,6 +47,7 @@ public void WrapFieldResponseWriteFile() } // NOT new sink as field is private + // neutral=Sinks;NewSinks;WrapPrivateFieldResponseWriteFile;();summary;df-generated public void WrapPrivateFieldResponseWriteFile() { var response = new HttpResponse(); @@ -48,6 +55,8 @@ public void WrapPrivateFieldResponseWriteFile() } // New sink + // sink=Sinks;NewSinks;false;WrapPropResponseWriteFile;();;Argument[this];html-injection;df-generated + // neutral=Sinks;NewSinks;WrapPropResponseWriteFile;();summary;df-generated public void WrapPropResponseWriteFile() { var response = new HttpResponse(); @@ -55,6 +64,7 @@ public void WrapPropResponseWriteFile() } // NOT new sink as property is private + // neutral=Sinks;NewSinks;WrapPrivatePropResponseWriteFile;();summary;df-generated public void WrapPrivatePropResponseWriteFile() { var response = new HttpResponse(); @@ -62,9 +72,10 @@ public void WrapPrivatePropResponseWriteFile() } // NOT new sink as property setter is private + // neutral=Sinks;NewSinks;WrapPropPrivateSetResponseWriteFile;();summary;df-generated public void WrapPropPrivateSetResponseWriteFile() { var response = new HttpResponse(); response.WriteFile(PrivateSetTaintedProp); } -} \ No newline at end of file +} diff --git a/csharp/ql/test/utils/modelgenerator/dataflow/Sources.cs b/csharp/ql/test/utils/modelgenerator/dataflow/Sources.cs index 1db0cd233b35..8d1edfc0b86d 100644 --- a/csharp/ql/test/utils/modelgenerator/dataflow/Sources.cs +++ b/csharp/ql/test/utils/modelgenerator/dataflow/Sources.cs @@ -5,12 +5,16 @@ namespace Sources; public class NewSources { // New source + // source=Sources;NewSources;false;WrapConsoleReadLine;();;ReturnValue;local;df-generated + // neutral=Sources;NewSources;WrapConsoleReadLine;();summary;df-generated public string? WrapConsoleReadLine() { return Console.ReadLine(); } // New source + // source=Sources;NewSources;false;WrapConsoleReadLineAndProcees;(System.String);;ReturnValue;local;df-generated + // neutral=Sources;NewSources;WrapConsoleReadLineAndProcees;(System.String);summary;df-generated public string WrapConsoleReadLineAndProcees(string prompt) { var s = Console.ReadLine(); @@ -24,8 +28,10 @@ public string WrapConsoleReadLineAndProcees(string prompt) } // New source + // source=Sources;NewSources;false;WrapConsoleReadKey;();;ReturnValue;local;df-generated + // neutral=Sources;NewSources;WrapConsoleReadKey;();summary;df-generated public ConsoleKeyInfo WrapConsoleReadKey() { return Console.ReadKey(); } -} \ No newline at end of file +} diff --git a/csharp/ql/test/utils/modelgenerator/dataflow/Summaries.cs b/csharp/ql/test/utils/modelgenerator/dataflow/Summaries.cs index 78934e61ee4b..c7266aa38a55 100644 --- a/csharp/ql/test/utils/modelgenerator/dataflow/Summaries.cs +++ b/csharp/ql/test/utils/modelgenerator/dataflow/Summaries.cs @@ -3,45 +3,53 @@ using System.Collections; using System.Collections.Generic; -namespace Summaries; +namespace Models; public class BasicFlow { - // No flow summary and no negative summary either. + // No model as destructors are excluded from model generation. ~BasicFlow() { } private string tainted; + // summary=Models;BasicFlow;false;ReturnThis;(System.Object);;Argument[this];ReturnValue;value;df-generated public BasicFlow ReturnThis(object input) { return this; } + // summary=Models;BasicFlow;false;ReturnParam0;(System.String,System.Object);;Argument[0];ReturnValue;taint;df-generated public string ReturnParam0(string input0, object input1) { return input0; } + // summary=Models;BasicFlow;false;ReturnParam1;(System.String,System.Object);;Argument[1];ReturnValue;taint;df-generated public object ReturnParam1(string input0, object input1) { return input1; } + // summary=Models;BasicFlow;false;ReturnParamMultiple;(System.Object,System.Object);;Argument[0];ReturnValue;taint;df-generated + // summary=Models;BasicFlow;false;ReturnParamMultiple;(System.Object,System.Object);;Argument[1];ReturnValue;taint;df-generated public object ReturnParamMultiple(object input0, object input1) { return (System.DateTime.Now.DayOfWeek == System.DayOfWeek.Monday) ? input0 : input1; } + // summary=Models;BasicFlow;false;ReturnSubstring;(System.String);;Argument[0];ReturnValue;taint;df-generated public string ReturnSubstring(string s) { return s.Substring(0, 1); } + // summary=Models;BasicFlow;false;SetField;(System.String);;Argument[0];Argument[this];taint;df-generated public void SetField(string s) { tainted = s; } + // summary=Models;BasicFlow;false;ReturnField;();;Argument[this];ReturnValue;taint;df-generated public string ReturnField() { return tainted; @@ -52,81 +60,118 @@ public class CollectionFlow { private string tainted; + // summary=Models;CollectionFlow;false;ReturnArrayElement;(System.Object[]);;Argument[0].Element;ReturnValue;taint;df-generated public object ReturnArrayElement(object[] input) { return input[0]; } + // summary=Models;CollectionFlow;false;AssignToArray;(System.Object,System.Object[]);;Argument[0];Argument[1].Element;taint;df-generated public void AssignToArray(object data, object[] target) { target[0] = data; } + // summary=Models;CollectionFlow;false;AssignFieldToArray;(System.Object[]);;Argument[this];Argument[0].Element;taint;df-generated public void AssignFieldToArray(object[] target) { target[0] = tainted; } + // summary=Models;CollectionFlow;false;ReturnListElement;(System.Collections.Generic.List);;Argument[0].Element;ReturnValue;taint;df-generated public object ReturnListElement(List input) { return input[0]; } + // summary=Models;CollectionFlow;false;AddToList;(System.Collections.Generic.List,System.Object);;Argument[1];Argument[0].Element;taint;df-generated public void AddToList(List input, object data) { input.Add(data); } + // summary=Models;CollectionFlow;false;AddFieldToList;(System.Collections.Generic.List);;Argument[this];Argument[0].Element;taint;df-generated public void AddFieldToList(List input) { input.Add(tainted); } + // summary=Models;CollectionFlow;false;ReturnFieldInAList;();;Argument[this];ReturnValue;taint;df-generated public List ReturnFieldInAList() { return new List { tainted }; } + // summary=Models;CollectionFlow;false;ReturnComplexTypeArray;(System.String[]);;Argument[0].Element;ReturnValue;taint;df-generated public string[] ReturnComplexTypeArray(string[] a) { return a; } + // summary=Models;CollectionFlow;false;ReturnBulkTypeList;(System.Collections.Generic.List);;Argument[0].Element;ReturnValue;taint;df-generated public List ReturnBulkTypeList(List a) { return a; } + // summary=Models;CollectionFlow;false;ReturnComplexTypeDictionary;(System.Collections.Generic.Dictionary);;Argument[0].Element;ReturnValue;taint;df-generated public Dictionary ReturnComplexTypeDictionary(Dictionary a) { return a; } + // summary=Models;CollectionFlow;false;ReturnUntypedArray;(System.Array);;Argument[0].Element;ReturnValue;taint;df-generated public Array ReturnUntypedArray(Array a) { return a; } + // summary=Models;CollectionFlow;false;ReturnUntypedList;(System.Collections.IList);;Argument[0].Element;ReturnValue;taint;df-generated public IList ReturnUntypedList(IList a) { return a; } + + // No flow as this is collection is of simple types. + // neutral=Models;CollectionFlow;ReturnSimpleTypeArray;(System.Int32[]);summary;df-generated + public int[] ReturnSimpleTypeArray(int[] a) + { + return a; + } + + // No flow as this is collection is of simple types. + // neutral=Models;CollectionFlow;ReturnSimpleTypeList;(System.Collections.Generic.List);summary;df-generated + public List ReturnSimpleTypeList(List a) + { + return a; + } + + // No flow as this is collection is of simple types. + // neutral=Models;CollectionFlow;ReturnSimpleTypeDictionary;(System.Collections.Generic.Dictionary);summary;df-generated + public Dictionary ReturnSimpleTypeDictionary(Dictionary a) + { + return a; + } + } public class IEnumerableFlow { private string tainted; + // summary=Models;IEnumerableFlow;false;ReturnIEnumerable;(System.Collections.Generic.IEnumerable);;Argument[0].Element;ReturnValue;taint;df-generated public IEnumerable ReturnIEnumerable(IEnumerable input) { return input; } + // summary=Models;IEnumerableFlow;false;ReturnIEnumerableElement;(System.Collections.Generic.IEnumerable);;Argument[0].Element;ReturnValue;taint;df-generated public object ReturnIEnumerableElement(IEnumerable input) { return input.First(); } + // summary=Models;IEnumerableFlow;false;ReturnFieldInIEnumerable;();;Argument[this];ReturnValue;taint;df-generated public IEnumerable ReturnFieldInIEnumerable() { return new List { tainted }; @@ -137,36 +182,43 @@ public class GenericFlow { private T tainted; + // summary=Models;GenericFlow;false;SetGenericField;(T);;Argument[0];Argument[this];taint;df-generated public void SetGenericField(T t) { tainted = t; } + // summary=Models;GenericFlow;false;ReturnGenericField;();;Argument[this];ReturnValue;taint;df-generated public T ReturnGenericField() { return tainted; } + // summary=Models;GenericFlow;false;AddFieldToGenericList;(System.Collections.Generic.List);;Argument[this];Argument[0].Element;taint;df-generated public void AddFieldToGenericList(List input) { input.Add(tainted); } + // summary=Models;GenericFlow;false;ReturnFieldInGenericList;();;Argument[this];ReturnValue;taint;df-generated public List ReturnFieldInGenericList() { return new List { tainted }; } + // summary=Models;GenericFlow;false;ReturnGenericParam;(S);;Argument[0];ReturnValue;taint;df-generated public S ReturnGenericParam(S input) { return input; } + // summary=Models;GenericFlow;false;ReturnGenericElement;(System.Collections.Generic.List);;Argument[0].Element;ReturnValue;taint;df-generated public S ReturnGenericElement(List input) { return input[0]; } + // summary=Models;GenericFlow;false;AddToGenericList;(System.Collections.Generic.List,S);;Argument[1];Argument[0].Element;taint;df-generated public void AddToGenericList(List input, S data) { input.Add(data); @@ -175,6 +227,7 @@ public void AddToGenericList(List input, S data) public abstract class BaseClassFlow { + // summary=Models;BaseClassFlow;true;ReturnParam;(System.Object);;Argument[0];ReturnValue;taint;df-generated public virtual object ReturnParam(object input) { return input; @@ -183,6 +236,7 @@ public virtual object ReturnParam(object input) public class DerivedClass1Flow : BaseClassFlow { + // summary=Models;DerivedClass1Flow;false;ReturnParam1;(System.String,System.String);;Argument[1];ReturnValue;taint;df-generated public string ReturnParam1(string input0, string input1) { return input1; @@ -191,11 +245,13 @@ public string ReturnParam1(string input0, string input1) public class DerivedClass2Flow : BaseClassFlow { + // summary=Models;DerivedClass2Flow;false;ReturnParam;(System.Object);;Argument[0];ReturnValue;taint;df-generated public override object ReturnParam(object input) { return input; } + // summary=Models;DerivedClass2Flow;false;ReturnParam0;(System.String,System.Int32);;Argument[0];ReturnValue;taint;df-generated public string ReturnParam0(string input0, int input1) { return input0; @@ -206,30 +262,35 @@ public class OperatorFlow { public readonly object Field; + // summary=Models;OperatorFlow;false;OperatorFlow;(System.Object);;Argument[0];Argument[this];taint;df-generated public OperatorFlow(object o) { Field = o; } // Flow Summary. + // summary=Models;OperatorFlow;false;op_Addition;(Models.OperatorFlow,Models.OperatorFlow);;Argument[0];ReturnValue;taint;df-generated public static OperatorFlow operator +(OperatorFlow a, OperatorFlow b) { return a; } // No flow summary. + // neutral=Models;OperatorFlow;op_Increment;(Models.OperatorFlow);summary;df-generated public static OperatorFlow operator ++(OperatorFlow a) { return new OperatorFlow(new object()); } - // No flow summary as this is an implicit conversion operator. + // No model as user defined conversion operators are excluded + // from model generation. public static implicit operator OperatorFlow(string s) { return new OperatorFlow(s); } - // No flow summary as this is an explicit conversion operator. + // No model as user defined conversion operators are excluded + // from model generation. public static explicit operator OperatorFlow(string[] b) { return new OperatorFlow(b); @@ -242,19 +303,19 @@ public class EqualsGetHashCodeNoFlow public readonly bool boolTainted; public readonly int intTainted; - // No flow summary as this is an override of the Equals method. + // neutral=Models;EqualsGetHashCodeNoFlow;Equals;(System.Object);summary;df-generated public override bool Equals(object obj) { return boolTainted; } - // Flow summary as this is not an override of the object Equals method. + // summary=Models;EqualsGetHashCodeNoFlow;false;Equals;(System.String);;Argument[0];ReturnValue;taint;df-generated public string Equals(string s) { return s; } - // No flow summary as this is an override of the GetHashCode method. + // neutral=Models;EqualsGetHashCodeNoFlow;GetHashCode;();summary;df-generated public override int GetHashCode() { return intTainted; @@ -265,13 +326,167 @@ public class Properties { private string tainted; + // summary=Models;Properties;false;get_Prop1;();;Argument[this];ReturnValue;taint;df-generated public string Prop1 { get { return tainted; } } + // summary=Models;Properties;false;set_Prop2;(System.String);;Argument[0];Argument[this];taint;df-generated public string Prop2 { set { tainted = value; } } + + public object backingField; + // No model as properties with public getters and setters are excluded from + // model generation as these are handled directly by the dataflow library. + public object Prop + { + get { return backingField; } + set { backingField = value; } + } +} + +// No models as the methods are not public. +public sealed class PublicClassNoFlow +{ + private object PrivateReturn(object input) + { + return input; + } + + internal object InternalReturn(object input) + { + return input; + } + + private class PrivateClassNoFlow + { + public object ReturnParam(object input) + { + return input; + } + } + + private class PrivateClassNestedPublicClassNoFlow + { + public class NestedPublicClassFlow + { + public object ReturnParam(object input) + { + return input; + } + } + } +} + +public class EquatableBound : IEquatable +{ + public readonly bool tainted; + + // neutral=Models;EquatableBound;Equals;(System.Object);summary;df-generated + public bool Equals(object other) + { + return tainted; + } +} + +public class EquatableUnBound : IEquatable +{ + public readonly bool tainted; + + // neutral=Models;EquatableUnBound;Equals;(T);summary;df-generated + public bool Equals(T? other) + { + return tainted; + } +} + +// No methods in this class will have generated flow summaries as +// simple types are used. +public class SimpleTypes +{ + // neutral=Models;SimpleTypes;M1;(System.Boolean);summary;df-generated + public bool M1(bool b) + { + return b; + } + + // neutral=Models;SimpleTypes;M2;(System.Boolean);summary;df-generated + public Boolean M2(Boolean b) + { + return b; + } + + // neutral=Models;SimpleTypes;M3;(System.Int32);summary;df-generated + public int M3(int i) + { + return i; + } + + // neutral=Models;SimpleTypes;M4;(System.Int32);summary;df-generated + public Int32 M4(Int32 i) + { + return i; + } +} + +// No models as higher order methods are excluded +// from model generation. +public class HigherOrderParameters +{ + public string M1(string s, Func map) + { + return s; + } + + public object M2(Func map, object o) + { + return map(o); + } +} + +public abstract class BaseClass +{ + // neutral=Models;BaseClass;M1;(System.String);summary;df-generated + public virtual string M1(string s) + { + return ""; + } + + // neutral=Models;BaseClass;M2;(System.String);summary;df-generated + public abstract string M2(string s); +} + +// No models as manually modelled methods are excluded from +// model generation. +public class ManuallyModelled +{ + public object HasSummary(object o) + { + return o; + } + + public object HasNeutralSummary(object o) + { + return o; + } + + public object HasNeutralSummaryNoFlow(object o) + { + return null; + } +} + +public class ParameterlessConstructor +{ + public bool IsInitialized; + + // No model as parameterless constructors + // are excluded from model generation. + public ParameterlessConstructor() + { + IsInitialized = true; + } } diff --git a/csharp/ql/test/utils/modelgenerator/typebasedflow/CaptureTypeBasedSummaryModels.expected b/csharp/ql/test/utils/modelgenerator/typebasedflow/CaptureTypeBasedSummaryModels.expected index f35f393adf5e..cb6fc390349c 100644 --- a/csharp/ql/test/utils/modelgenerator/typebasedflow/CaptureTypeBasedSummaryModels.expected +++ b/csharp/ql/test/utils/modelgenerator/typebasedflow/CaptureTypeBasedSummaryModels.expected @@ -1,162 +1,2 @@ -| Summaries;IGrouping;true;get_Key;();;Argument[this].SyntheticField[ArgType0];ReturnValue;value;tb-generated | -| Summaries;IOrderedEnumerable;true;CreateOrderedEnumerable;(System.Func,System.Collections.Generic.IComparer,System.Boolean);;Argument[this].Element;Argument[0].Parameter[0];value;tb-generated | -| Summaries;IOrderedEnumerable;true;CreateOrderedEnumerable;(System.Func,System.Collections.Generic.IComparer,System.Boolean);;Argument[this].Element;ReturnValue.Element;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Aggregate;(System.Collections.Generic.IEnumerable,TAccumulate,System.Func,System.Func);;Argument[0].Element;Argument[2].Parameter[1];value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Aggregate;(System.Collections.Generic.IEnumerable,TAccumulate,System.Func,System.Func);;Argument[1];Argument[2].Parameter[0];value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Aggregate;(System.Collections.Generic.IEnumerable,TAccumulate,System.Func,System.Func);;Argument[1];Argument[3].Parameter[0];value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Aggregate;(System.Collections.Generic.IEnumerable,TAccumulate,System.Func,System.Func);;Argument[2].ReturnValue;Argument[2].Parameter[0];value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Aggregate;(System.Collections.Generic.IEnumerable,TAccumulate,System.Func,System.Func);;Argument[2].ReturnValue;Argument[3].Parameter[0];value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Aggregate;(System.Collections.Generic.IEnumerable,TAccumulate,System.Func,System.Func);;Argument[3].ReturnValue;ReturnValue;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Aggregate;(System.Collections.Generic.IEnumerable,TAccumulate,System.Func);;Argument[0].Element;Argument[2].Parameter[1];value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Aggregate;(System.Collections.Generic.IEnumerable,TAccumulate,System.Func);;Argument[1];Argument[2].Parameter[0];value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Aggregate;(System.Collections.Generic.IEnumerable,TAccumulate,System.Func);;Argument[1];ReturnValue;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Aggregate;(System.Collections.Generic.IEnumerable,TAccumulate,System.Func);;Argument[2].ReturnValue;Argument[2].Parameter[0];value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Aggregate;(System.Collections.Generic.IEnumerable,TAccumulate,System.Func);;Argument[2].ReturnValue;ReturnValue;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Aggregate;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Aggregate;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[1];value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Aggregate;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;ReturnValue;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Aggregate;(System.Collections.Generic.IEnumerable,System.Func);;Argument[1].ReturnValue;Argument[1].Parameter[0];value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Aggregate;(System.Collections.Generic.IEnumerable,System.Func);;Argument[1].ReturnValue;Argument[1].Parameter[1];value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Aggregate;(System.Collections.Generic.IEnumerable,System.Func);;Argument[1].ReturnValue;ReturnValue;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;All;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Any;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Append;(System.Collections.Generic.IEnumerable,TSource);;Argument[0].Element;ReturnValue.Element;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Append;(System.Collections.Generic.IEnumerable,TSource);;Argument[1];ReturnValue.Element;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;AsEnumerable;(System.Collections.Generic.IEnumerable);;Argument[0].Element;ReturnValue.Element;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Average;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Concat;(System.Collections.Generic.IEnumerable,System.Collections.Generic.IEnumerable);;Argument[0].Element;ReturnValue.Element;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Concat;(System.Collections.Generic.IEnumerable,System.Collections.Generic.IEnumerable);;Argument[1].Element;ReturnValue.Element;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Count;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated | -| Summaries;SystemLinqEnumerable;false;DefaultIfEmpty;(System.Collections.Generic.IEnumerable);;Argument[0].Element;ReturnValue.Element;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;DefaultIfEmpty;(System.Collections.Generic.IEnumerable,TSource);;Argument[0].Element;ReturnValue.Element;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;DefaultIfEmpty;(System.Collections.Generic.IEnumerable,TSource);;Argument[1];ReturnValue.Element;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Distinct;(System.Collections.Generic.IEnumerable);;Argument[0].Element;ReturnValue.Element;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;DistinctBy;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated | -| Summaries;SystemLinqEnumerable;false;DistinctBy;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;ReturnValue.Element;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;ElementAt;(System.Collections.Generic.IEnumerable,System.Int32);;Argument[0].Element;ReturnValue;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;ElementAtOrDefault;(System.Collections.Generic.IEnumerable,System.Int32);;Argument[0].Element;ReturnValue;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;First;(System.Collections.Generic.IEnumerable);;Argument[0].Element;ReturnValue;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;First;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated | -| Summaries;SystemLinqEnumerable;false;First;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;ReturnValue;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;FirstOrDefault;(System.Collections.Generic.IEnumerable);;Argument[0].Element;ReturnValue;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;FirstOrDefault;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated | -| Summaries;SystemLinqEnumerable;false;FirstOrDefault;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;ReturnValue;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;FirstOrDefault;(System.Collections.Generic.IEnumerable,TSource);;Argument[0].Element;ReturnValue;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;FirstOrDefault;(System.Collections.Generic.IEnumerable,TSource);;Argument[1];ReturnValue;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Intersect;(System.Collections.Generic.IEnumerable,System.Collections.Generic.IEnumerable);;Argument[0].Element;ReturnValue.Element;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Intersect;(System.Collections.Generic.IEnumerable,System.Collections.Generic.IEnumerable);;Argument[1].Element;ReturnValue.Element;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;IntersectBy;(System.Collections.Generic.IEnumerable,System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[2].Parameter[0];value;tb-generated | -| Summaries;SystemLinqEnumerable;false;IntersectBy;(System.Collections.Generic.IEnumerable,System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;ReturnValue.Element;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Join;(System.Collections.Generic.IEnumerable,System.Collections.Generic.IEnumerable,System.Func,System.Func,System.Func);;Argument[0].Element;Argument[2].Parameter[0];value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Join;(System.Collections.Generic.IEnumerable,System.Collections.Generic.IEnumerable,System.Func,System.Func,System.Func);;Argument[0].Element;Argument[4].Parameter[0];value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Join;(System.Collections.Generic.IEnumerable,System.Collections.Generic.IEnumerable,System.Func,System.Func,System.Func);;Argument[1].Element;Argument[3].Parameter[0];value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Join;(System.Collections.Generic.IEnumerable,System.Collections.Generic.IEnumerable,System.Func,System.Func,System.Func);;Argument[1].Element;Argument[4].Parameter[1];value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Join;(System.Collections.Generic.IEnumerable,System.Collections.Generic.IEnumerable,System.Func,System.Func,System.Func);;Argument[4].ReturnValue;ReturnValue.Element;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Last;(System.Collections.Generic.IEnumerable);;Argument[0].Element;ReturnValue;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Last;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Last;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;ReturnValue;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;LastOrDefault;(System.Collections.Generic.IEnumerable);;Argument[0].Element;ReturnValue;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;LastOrDefault;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated | -| Summaries;SystemLinqEnumerable;false;LastOrDefault;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;ReturnValue;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;LastOrDefault;(System.Collections.Generic.IEnumerable,TSource);;Argument[0].Element;ReturnValue;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;LastOrDefault;(System.Collections.Generic.IEnumerable,TSource);;Argument[1];ReturnValue;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;LongCount;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Max;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Max;(System.Collections.Generic.IEnumerable,System.Func);;Argument[1].ReturnValue;ReturnValue;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Max;(System.Collections.Generic.IEnumerable);;Argument[0].Element;ReturnValue;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Max;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated | -| Summaries;SystemLinqEnumerable;false;MaxBy;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated | -| Summaries;SystemLinqEnumerable;false;MaxBy;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;ReturnValue;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Min;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Min;(System.Collections.Generic.IEnumerable,System.Func);;Argument[1].ReturnValue;ReturnValue;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Min;(System.Collections.Generic.IEnumerable);;Argument[0].Element;ReturnValue;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;MinBy;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated | -| Summaries;SystemLinqEnumerable;false;MinBy;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;ReturnValue;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;OrderBy;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated | -| Summaries;SystemLinqEnumerable;false;OrderBy;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;ReturnValue.Element;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;OrderByDescending;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated | -| Summaries;SystemLinqEnumerable;false;OrderByDescending;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;ReturnValue.Element;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Prepend;(System.Collections.Generic.IEnumerable,TSource);;Argument[0].Element;ReturnValue.Element;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Prepend;(System.Collections.Generic.IEnumerable,TSource);;Argument[1];ReturnValue.Element;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Repeat;(TResult,System.Int32);;Argument[0];ReturnValue.Element;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Reverse;(System.Collections.Generic.IEnumerable);;Argument[0].Element;ReturnValue.Element;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Select;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Select;(System.Collections.Generic.IEnumerable,System.Func);;Argument[1].ReturnValue;ReturnValue.Element;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;SelectMany;(System.Collections.Generic.IEnumerable,System.Func>,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated | -| Summaries;SystemLinqEnumerable;false;SelectMany;(System.Collections.Generic.IEnumerable,System.Func>,System.Func);;Argument[0].Element;Argument[2].Parameter[0];value;tb-generated | -| Summaries;SystemLinqEnumerable;false;SelectMany;(System.Collections.Generic.IEnumerable,System.Func>,System.Func);;Argument[1].ReturnValue.Element;Argument[2].Parameter[1];value;tb-generated | -| Summaries;SystemLinqEnumerable;false;SelectMany;(System.Collections.Generic.IEnumerable,System.Func>,System.Func);;Argument[2].ReturnValue;ReturnValue.Element;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;SelectMany;(System.Collections.Generic.IEnumerable,System.Func>);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated | -| Summaries;SystemLinqEnumerable;false;SelectMany;(System.Collections.Generic.IEnumerable,System.Func>);;Argument[1].ReturnValue.Element;ReturnValue.Element;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Single;(System.Collections.Generic.IEnumerable);;Argument[0].Element;ReturnValue;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Single;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Single;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;ReturnValue;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;SingleOrDefault;(System.Collections.Generic.IEnumerable);;Argument[0].Element;ReturnValue;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;SingleOrDefault;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated | -| Summaries;SystemLinqEnumerable;false;SingleOrDefault;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;ReturnValue;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;SingleOrDefault;(System.Collections.Generic.IEnumerable,TSource);;Argument[0].Element;ReturnValue;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;SingleOrDefault;(System.Collections.Generic.IEnumerable,TSource);;Argument[1];ReturnValue;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Skip;(System.Collections.Generic.IEnumerable,System.Int32);;Argument[0].Element;ReturnValue.Element;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;SkipLast;(System.Collections.Generic.IEnumerable,System.Int32);;Argument[0].Element;ReturnValue.Element;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;SkipWhile;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated | -| Summaries;SystemLinqEnumerable;false;SkipWhile;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;ReturnValue.Element;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Take;(System.Collections.Generic.IEnumerable,System.Int32);;Argument[0].Element;ReturnValue.Element;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;TakeLast;(System.Collections.Generic.IEnumerable,System.Int32);;Argument[0].Element;ReturnValue.Element;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;TakeWhile;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated | -| Summaries;SystemLinqEnumerable;false;TakeWhile;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;ReturnValue.Element;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;ThenBy;(Summaries.IOrderedEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated | -| Summaries;SystemLinqEnumerable;false;ThenBy;(Summaries.IOrderedEnumerable,System.Func);;Argument[0].Element;ReturnValue.Element;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;ThenByDescending;(Summaries.IOrderedEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated | -| Summaries;SystemLinqEnumerable;false;ThenByDescending;(Summaries.IOrderedEnumerable,System.Func);;Argument[0].Element;ReturnValue.Element;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;ToHashSet;(System.Collections.Generic.IEnumerable);;Argument[0].Element;ReturnValue.Element;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;ToList;(System.Collections.Generic.IEnumerable);;Argument[0].Element;ReturnValue.Element;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Union;(System.Collections.Generic.IEnumerable,System.Collections.Generic.IEnumerable);;Argument[0].Element;ReturnValue.Element;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Union;(System.Collections.Generic.IEnumerable,System.Collections.Generic.IEnumerable);;Argument[1].Element;ReturnValue.Element;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;UnionBy;(System.Collections.Generic.IEnumerable,System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[2].Parameter[0];value;tb-generated | -| Summaries;SystemLinqEnumerable;false;UnionBy;(System.Collections.Generic.IEnumerable,System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;ReturnValue.Element;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;UnionBy;(System.Collections.Generic.IEnumerable,System.Collections.Generic.IEnumerable,System.Func);;Argument[1].Element;Argument[2].Parameter[0];value;tb-generated | -| Summaries;SystemLinqEnumerable;false;UnionBy;(System.Collections.Generic.IEnumerable,System.Collections.Generic.IEnumerable,System.Func);;Argument[1].Element;ReturnValue.Element;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Where;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Where;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;ReturnValue.Element;value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Zip;(System.Collections.Generic.IEnumerable,System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[2].Parameter[0];value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Zip;(System.Collections.Generic.IEnumerable,System.Collections.Generic.IEnumerable,System.Func);;Argument[1].Element;Argument[2].Parameter[1];value;tb-generated | -| Summaries;SystemLinqEnumerable;false;Zip;(System.Collections.Generic.IEnumerable,System.Collections.Generic.IEnumerable,System.Func);;Argument[2].ReturnValue;ReturnValue.Element;value;tb-generated | -| Summaries;TypeBasedCollection;false;Add;(T);;Argument[0];Argument[this].Element;value;tb-generated | -| Summaries;TypeBasedCollection;false;AddMany;(System.Collections.Generic.IEnumerable);;Argument[0].Element;Argument[this].Element;value;tb-generated | -| Summaries;TypeBasedCollection;false;First;();;Argument[this].Element;ReturnValue;value;tb-generated | -| Summaries;TypeBasedCollection;false;GetMany;();;Argument[this].Element;ReturnValue.Element;value;tb-generated | -| Summaries;TypeBasedComplex;false;AddMany;(System.Collections.Generic.IEnumerable);;Argument[0].Element;Argument[this].SyntheticField[ArgType0];value;tb-generated | -| Summaries;TypeBasedComplex;false;Apply;(System.Func);;Argument[this].SyntheticField[ArgType0];Argument[0].Parameter[0];value;tb-generated | -| Summaries;TypeBasedComplex;false;Apply;(System.Func);;Argument[0].ReturnValue;ReturnValue;value;tb-generated | -| Summaries;TypeBasedComplex;false;Apply;(System.Func);;Argument[this].SyntheticField[ArgType0];Argument[0].Parameter[0];value;tb-generated | -| Summaries;TypeBasedComplex;false;Apply;(T1,System.Func);;Argument[0];Argument[1].Parameter[0];value;tb-generated | -| Summaries;TypeBasedComplex;false;Apply;(T1,System.Func);;Argument[1].ReturnValue;ReturnValue;value;tb-generated | -| Summaries;TypeBasedComplex;false;FlatMap;(System.Func>);;Argument[0].ReturnValue.Element;Argument[0].Parameter[0];value;tb-generated | -| Summaries;TypeBasedComplex;false;FlatMap;(System.Func>);;Argument[0].ReturnValue.Element;Argument[this].SyntheticField[ArgType0];value;tb-generated | -| Summaries;TypeBasedComplex;false;FlatMap;(System.Func>);;Argument[0].ReturnValue.Element;ReturnValue.SyntheticField[ArgType0];value;tb-generated | -| Summaries;TypeBasedComplex;false;FlatMap;(System.Func>);;Argument[this].SyntheticField[ArgType0];Argument[0].Parameter[0];value;tb-generated | -| Summaries;TypeBasedComplex;false;FlatMap;(System.Func>);;Argument[this].SyntheticField[ArgType0];ReturnValue.SyntheticField[ArgType0];value;tb-generated | -| Summaries;TypeBasedComplex;false;FlatMap;(System.Func>);;Argument[0].ReturnValue.Element;ReturnValue.SyntheticField[ArgType0];value;tb-generated | -| Summaries;TypeBasedComplex;false;FlatMap;(System.Func>);;Argument[this].SyntheticField[ArgType0];Argument[0].Parameter[0];value;tb-generated | -| Summaries;TypeBasedComplex;false;GetMany;();;Argument[this].SyntheticField[ArgType0];ReturnValue.Element;value;tb-generated | -| Summaries;TypeBasedComplex;false;Map;(System.Func);;Argument[0].ReturnValue;ReturnValue;value;tb-generated | -| Summaries;TypeBasedComplex;false;Map;(System.Func);;Argument[this].SyntheticField[ArgType0];Argument[0].Parameter[0];value;tb-generated | -| Summaries;TypeBasedComplex;false;MapComplex;(System.Func);;Argument[0].ReturnValue;ReturnValue.SyntheticField[ArgType0];value;tb-generated | -| Summaries;TypeBasedComplex;false;MapComplex;(System.Func);;Argument[this].SyntheticField[ArgType0];Argument[0].Parameter[0];value;tb-generated | -| Summaries;TypeBasedComplex;false;Return;(System.Func>);;Argument[0].ReturnValue.SyntheticField[ArgType0];Argument[0].Parameter[0];value;tb-generated | -| Summaries;TypeBasedComplex;false;Return;(System.Func>);;Argument[0].ReturnValue.SyntheticField[ArgType0];Argument[this].SyntheticField[ArgType0];value;tb-generated | -| Summaries;TypeBasedComplex;false;Return;(System.Func>);;Argument[0].ReturnValue.SyntheticField[ArgType0];ReturnValue.SyntheticField[ArgType0];value;tb-generated | -| Summaries;TypeBasedComplex;false;Return;(System.Func>);;Argument[this].SyntheticField[ArgType0];Argument[0].Parameter[0];value;tb-generated | -| Summaries;TypeBasedComplex;false;Return;(System.Func>);;Argument[this].SyntheticField[ArgType0];ReturnValue.SyntheticField[ArgType0];value;tb-generated | -| Summaries;TypeBasedComplex;false;Set;(System.Int32,System.Func);;Argument[1].ReturnValue;Argument[this].SyntheticField[ArgType0];value;tb-generated | -| Summaries;TypeBasedNoCollection;false;Get;();;Argument[this].SyntheticField[ArgType0];ReturnValue;value;tb-generated | -| Summaries;TypeBasedNoCollection;false;Set;(T);;Argument[0];Argument[this].SyntheticField[ArgType0];value;tb-generated | -| Summaries;TypeBasedSimple;false;Get;();;Argument[this].SyntheticField[ArgType0];ReturnValue;value;tb-generated | -| Summaries;TypeBasedSimple;false;Get;(System.Object);;Argument[this].SyntheticField[ArgType0];ReturnValue;value;tb-generated | -| Summaries;TypeBasedSimple;false;Id;(T);;Argument[0];Argument[this].SyntheticField[ArgType0];value;tb-generated | -| Summaries;TypeBasedSimple;false;Id;(T);;Argument[0];ReturnValue;value;tb-generated | -| Summaries;TypeBasedSimple;false;Id;(T);;Argument[this].SyntheticField[ArgType0];ReturnValue;value;tb-generated | -| Summaries;TypeBasedSimple;false;Id;(S);;Argument[0];ReturnValue;value;tb-generated | -| Summaries;TypeBasedSimple;false;Set;(System.Int32,T);;Argument[1];Argument[this].SyntheticField[ArgType0];value;tb-generated | -| Summaries;TypeBasedSimple;false;Set;(T);;Argument[0];Argument[this].SyntheticField[ArgType0];value;tb-generated | -| Summaries;TypeBasedSimple;false;TypeBasedSimple;(T);;Argument[0];Argument[this].SyntheticField[ArgType0];value;tb-generated | +unexpectedModel +expectedModel diff --git a/csharp/ql/test/utils/modelgenerator/typebasedflow/CaptureTypeBasedSummaryModels.ql b/csharp/ql/test/utils/modelgenerator/typebasedflow/CaptureTypeBasedSummaryModels.ql new file mode 100644 index 000000000000..b82afaf71c0a --- /dev/null +++ b/csharp/ql/test/utils/modelgenerator/typebasedflow/CaptureTypeBasedSummaryModels.ql @@ -0,0 +1,11 @@ +import csharp +import TestUtilities.InlineMadTest +import utils.modelgenerator.internal.CaptureTypeBasedSummaryModels + +module InlineMadTestConfig implements InlineMadTestConfigSig { + string getCapturedModel(Callable c) { result = captureFlow(c) } + + string getKind() { result = "summary" } +} + +import InlineMadTest diff --git a/csharp/ql/test/utils/modelgenerator/typebasedflow/CaptureTypeBasedSummaryModels.qlref b/csharp/ql/test/utils/modelgenerator/typebasedflow/CaptureTypeBasedSummaryModels.qlref deleted file mode 100644 index 73821d0ff846..000000000000 --- a/csharp/ql/test/utils/modelgenerator/typebasedflow/CaptureTypeBasedSummaryModels.qlref +++ /dev/null @@ -1 +0,0 @@ -utils/modelgenerator/CaptureTypeBasedSummaryModels.ql \ No newline at end of file diff --git a/csharp/ql/test/utils/modelgenerator/typebasedflow/TypeBasedSummaries.cs b/csharp/ql/test/utils/modelgenerator/typebasedflow/TypeBasedSummaries.cs index f87563b945d9..7582d07719c4 100644 --- a/csharp/ql/test/utils/modelgenerator/typebasedflow/TypeBasedSummaries.cs +++ b/csharp/ql/test/utils/modelgenerator/typebasedflow/TypeBasedSummaries.cs @@ -5,75 +5,119 @@ namespace Summaries; -public class TypeBasedSimple { - - public T Prop { +public class TypeBasedSimple +{ + + public T Prop + { get { throw null; } set { throw null; } } - public TypeBasedSimple(T t) { throw null; } + // summary=Summaries;TypeBasedSimple;false;TypeBasedSimple;(T);;Argument[0];Argument[this].SyntheticField[ArgType0];value;tb-generated + public TypeBasedSimple(T t) { throw null; } + // summary=Summaries;TypeBasedSimple;false;Get;();;Argument[this].SyntheticField[ArgType0];ReturnValue;value;tb-generated public T Get() { throw null; } + // summary=Summaries;TypeBasedSimple;false;Get;(System.Object);;Argument[this].SyntheticField[ArgType0];ReturnValue;value;tb-generated public T Get(object x) { throw null; } + // summary=Summaries;TypeBasedSimple;false;Id;(T);;Argument[0];Argument[this].SyntheticField[ArgType0];value;tb-generated + // summary=Summaries;TypeBasedSimple;false;Id;(T);;Argument[0];ReturnValue;value;tb-generated + // summary=Summaries;TypeBasedSimple;false;Id;(T);;Argument[this].SyntheticField[ArgType0];ReturnValue;value;tb-generated public T Id(T x) { throw null; } + // summary=Summaries;TypeBasedSimple;false;Id;(S);;Argument[0];ReturnValue;value;tb-generated public S Id(S x) { throw null; } + // summary=Summaries;TypeBasedSimple;false;Set;(T);;Argument[0];Argument[this].SyntheticField[ArgType0];value;tb-generated public void Set(T x) { throw null; } + // summary=Summaries;TypeBasedSimple;false;Set;(System.Int32,T);;Argument[1];Argument[this].SyntheticField[ArgType0];value;tb-generated public void Set(int x, T y) { throw null; } - public void Set(S x) { throw null; } // No summary as S is unrelated to T + // No summary as S is unrelated to T + public void Set(S x) { throw null; } } -public class TypeBasedComplex { - +public class TypeBasedComplex +{ + // summary=Summaries;TypeBasedComplex;false;AddMany;(System.Collections.Generic.IEnumerable);;Argument[0].Element;Argument[this].SyntheticField[ArgType0];value;tb-generated public void AddMany(IEnumerable xs) { throw null; } + // summary=Summaries;TypeBasedComplex;false;Apply;(System.Func);;Argument[this].SyntheticField[ArgType0];Argument[0].Parameter[0];value;tb-generated public int Apply(Func f) { throw null; } + // summary=Summaries;TypeBasedComplex;false;Apply;(System.Func);;Argument[0].ReturnValue;ReturnValue;value;tb-generated + // summary=Summaries;TypeBasedComplex;false;Apply;(System.Func);;Argument[this].SyntheticField[ArgType0];Argument[0].Parameter[0];value;tb-generated public S Apply(Func f) { throw null; } - public T2 Apply(T1 x, Func f) { throw null; } + // summary=Summaries;TypeBasedComplex;false;Apply;(T1,System.Func);;Argument[0];Argument[1].Parameter[0];value;tb-generated + // summary=Summaries;TypeBasedComplex;false;Apply;(T1,System.Func);;Argument[1].ReturnValue;ReturnValue;value;tb-generated + public T2 Apply(T1 x, Func f) { throw null; } + // summary=Summaries;TypeBasedComplex;false;FlatMap;(System.Func>);;Argument[0].ReturnValue.Element;Argument[0].Parameter[0];value;tb-generated + // summary=Summaries;TypeBasedComplex;false;FlatMap;(System.Func>);;Argument[0].ReturnValue.Element;Argument[this].SyntheticField[ArgType0];value;tb-generated + // summary=Summaries;TypeBasedComplex;false;FlatMap;(System.Func>);;Argument[0].ReturnValue.Element;ReturnValue.SyntheticField[ArgType0];value;tb-generated + // summary=Summaries;TypeBasedComplex;false;FlatMap;(System.Func>);;Argument[this].SyntheticField[ArgType0];Argument[0].Parameter[0];value;tb-generated + // summary=Summaries;TypeBasedComplex;false;FlatMap;(System.Func>);;Argument[this].SyntheticField[ArgType0];ReturnValue.SyntheticField[ArgType0];value;tb-generated public TypeBasedComplex FlatMap(Func> f) { throw null; } + // summary=Summaries;TypeBasedComplex;false;FlatMap;(System.Func>);;Argument[0].ReturnValue.Element;ReturnValue.SyntheticField[ArgType0];value;tb-generated + // summary=Summaries;TypeBasedComplex;false;FlatMap;(System.Func>);;Argument[this].SyntheticField[ArgType0];Argument[0].Parameter[0];value;tb-generated public TypeBasedComplex FlatMap(Func> f) { throw null; } + // summary=Summaries;TypeBasedComplex;false;GetMany;();;Argument[this].SyntheticField[ArgType0];ReturnValue.Element;value;tb-generated public IList GetMany() { throw null; } + // summary=Summaries;TypeBasedComplex;false;Map;(System.Func);;Argument[0].ReturnValue;ReturnValue;value;tb-generated + // summary=Summaries;TypeBasedComplex;false;Map;(System.Func);;Argument[this].SyntheticField[ArgType0];Argument[0].Parameter[0];value;tb-generated public S Map(Func f) { throw null; } + // summary=Summaries;TypeBasedComplex;false;MapComplex;(System.Func);;Argument[0].ReturnValue;ReturnValue.SyntheticField[ArgType0];value;tb-generated + // summary=Summaries;TypeBasedComplex;false;MapComplex;(System.Func);;Argument[this].SyntheticField[ArgType0];Argument[0].Parameter[0];value;tb-generated public TypeBasedComplex MapComplex(Func f) { throw null; } + // summary=Summaries;TypeBasedComplex;false;Return;(System.Func>);;Argument[0].ReturnValue.SyntheticField[ArgType0];Argument[0].Parameter[0];value;tb-generated + // summary=Summaries;TypeBasedComplex;false;Return;(System.Func>);;Argument[0].ReturnValue.SyntheticField[ArgType0];Argument[this].SyntheticField[ArgType0];value;tb-generated + // summary=Summaries;TypeBasedComplex;false;Return;(System.Func>);;Argument[0].ReturnValue.SyntheticField[ArgType0];ReturnValue.SyntheticField[ArgType0];value;tb-generated + // summary=Summaries;TypeBasedComplex;false;Return;(System.Func>);;Argument[this].SyntheticField[ArgType0];Argument[0].Parameter[0];value;tb-generated + // summary=Summaries;TypeBasedComplex;false;Return;(System.Func>);;Argument[this].SyntheticField[ArgType0];ReturnValue.SyntheticField[ArgType0];value;tb-generated public TypeBasedComplex Return(Func> f) { throw null; } - - public void Set(int x, Func f) { throw null;} + + // summary=Summaries;TypeBasedComplex;false;Set;(System.Int32,System.Func);;Argument[1].ReturnValue;Argument[this].SyntheticField[ArgType0];value;tb-generated + public void Set(int x, Func f) { throw null; } } // It is assumed that this is a collection with elements of type T. -public class TypeBasedCollection : IEnumerable { +public class TypeBasedCollection : IEnumerable +{ IEnumerator IEnumerable.GetEnumerator() { throw null; } IEnumerator IEnumerable.GetEnumerator() { throw null; } + // summary=Summaries;TypeBasedCollection;false;Add;(T);;Argument[0];Argument[this].Element;value;tb-generated public void Add(T x) { throw null; } + // summary=Summaries;TypeBasedCollection;false;AddMany;(System.Collections.Generic.IEnumerable);;Argument[0].Element;Argument[this].Element;value;tb-generated public void AddMany(IEnumerable x) { throw null; } + // summary=Summaries;TypeBasedCollection;false;First;();;Argument[this].Element;ReturnValue;value;tb-generated public T First() { throw null; } + // summary=Summaries;TypeBasedCollection;false;GetMany;();;Argument[this].Element;ReturnValue.Element;value;tb-generated public ICollection GetMany() { throw null; } } // It is assumed that this is NOT a collection with elements of type T. -public class TypeBasedNoCollection : IEnumerable { +public class TypeBasedNoCollection : IEnumerable +{ IEnumerator IEnumerable.GetEnumerator() { throw null; } + // summary=Summaries;TypeBasedNoCollection;false;Get;();;Argument[this].SyntheticField[ArgType0];ReturnValue;value;tb-generated public T Get() { throw null; } + // summary=Summaries;TypeBasedNoCollection;false;Set;(T);;Argument[0];Argument[this].SyntheticField[ArgType0];value;tb-generated public void Set(T x) { throw null; } } @@ -85,108 +129,307 @@ public class TypeBasedNoCollection : IEnumerable { * In some cases we will not be able correctly generate a summary based purely on the * type information. */ -public static class SystemLinqEnumerable { - +public static class SystemLinqEnumerable +{ + // summary=Summaries;SystemLinqEnumerable;false;Aggregate;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;Aggregate;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[1];value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;Aggregate;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;ReturnValue;value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;Aggregate;(System.Collections.Generic.IEnumerable,System.Func);;Argument[1].ReturnValue;Argument[1].Parameter[0];value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;Aggregate;(System.Collections.Generic.IEnumerable,System.Func);;Argument[1].ReturnValue;Argument[1].Parameter[1];value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;Aggregate;(System.Collections.Generic.IEnumerable,System.Func);;Argument[1].ReturnValue;ReturnValue;value;tb-generated public static TSource Aggregate(this IEnumerable source, Func func) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;Aggregate;(System.Collections.Generic.IEnumerable,TAccumulate,System.Func);;Argument[0].Element;Argument[2].Parameter[1];value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;Aggregate;(System.Collections.Generic.IEnumerable,TAccumulate,System.Func);;Argument[1];Argument[2].Parameter[0];value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;Aggregate;(System.Collections.Generic.IEnumerable,TAccumulate,System.Func);;Argument[1];ReturnValue;value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;Aggregate;(System.Collections.Generic.IEnumerable,TAccumulate,System.Func);;Argument[2].ReturnValue;Argument[2].Parameter[0];value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;Aggregate;(System.Collections.Generic.IEnumerable,TAccumulate,System.Func);;Argument[2].ReturnValue;ReturnValue;value;tb-generated public static TAccumulate Aggregate(this IEnumerable source, TAccumulate seed, Func func) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;Aggregate;(System.Collections.Generic.IEnumerable,TAccumulate,System.Func,System.Func);;Argument[0].Element;Argument[2].Parameter[1];value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;Aggregate;(System.Collections.Generic.IEnumerable,TAccumulate,System.Func,System.Func);;Argument[1];Argument[2].Parameter[0];value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;Aggregate;(System.Collections.Generic.IEnumerable,TAccumulate,System.Func,System.Func);;Argument[1];Argument[3].Parameter[0];value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;Aggregate;(System.Collections.Generic.IEnumerable,TAccumulate,System.Func,System.Func);;Argument[2].ReturnValue;Argument[2].Parameter[0];value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;Aggregate;(System.Collections.Generic.IEnumerable,TAccumulate,System.Func,System.Func);;Argument[2].ReturnValue;Argument[3].Parameter[0];value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;Aggregate;(System.Collections.Generic.IEnumerable,TAccumulate,System.Func,System.Func);;Argument[3].ReturnValue;ReturnValue;value;tb-generated public static TResult Aggregate(this IEnumerable source, TAccumulate seed, Func func, Func resultSelector) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;All;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated public static bool All(this IEnumerable source, Func predicate) { throw null; } public static bool Any(this IEnumerable source) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;Any;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated public static bool Any(this IEnumerable source, Func predicate) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;Append;(System.Collections.Generic.IEnumerable,TSource);;Argument[0].Element;ReturnValue.Element;value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;Append;(System.Collections.Generic.IEnumerable,TSource);;Argument[1];ReturnValue.Element;value;tb-generated public static IEnumerable Append(this IEnumerable source, TSource element) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;AsEnumerable;(System.Collections.Generic.IEnumerable);;Argument[0].Element;ReturnValue.Element;value;tb-generated public static IEnumerable AsEnumerable(this IEnumerable source) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;Average;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated public static decimal Average(this IEnumerable source, Func selector) { throw null; } + // Summary will not be derivables based on type information. // public static IEnumerable Cast(this IEnumerable source) { throw null; } public static IEnumerable Chunk(this IEnumerable source, int size) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;Concat;(System.Collections.Generic.IEnumerable,System.Collections.Generic.IEnumerable);;Argument[0].Element;ReturnValue.Element;value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;Concat;(System.Collections.Generic.IEnumerable,System.Collections.Generic.IEnumerable);;Argument[1].Element;ReturnValue.Element;value;tb-generated public static IEnumerable Concat(this IEnumerable first, IEnumerable second) { throw null; } + public static bool Contains(this IEnumerable source, TSource value) { throw null; } + public static int Count(this IEnumerable source) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;Count;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated public static int Count(this IEnumerable source, Func predicate) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;DefaultIfEmpty;(System.Collections.Generic.IEnumerable);;Argument[0].Element;ReturnValue.Element;value;tb-generated public static IEnumerable DefaultIfEmpty(this IEnumerable source) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;DefaultIfEmpty;(System.Collections.Generic.IEnumerable,TSource);;Argument[0].Element;ReturnValue.Element;value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;DefaultIfEmpty;(System.Collections.Generic.IEnumerable,TSource);;Argument[1];ReturnValue.Element;value;tb-generated public static IEnumerable DefaultIfEmpty(this IEnumerable source, TSource defaultValue) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;DistinctBy;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;DistinctBy;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;ReturnValue.Element;value;tb-generated public static IEnumerable DistinctBy(this IEnumerable source, Func keySelector) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;Distinct;(System.Collections.Generic.IEnumerable);;Argument[0].Element;ReturnValue.Element;value;tb-generated public static IEnumerable Distinct(this IEnumerable source) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;ElementAtOrDefault;(System.Collections.Generic.IEnumerable,System.Int32);;Argument[0].Element;ReturnValue;value;tb-generated public static TSource? ElementAtOrDefault(this IEnumerable source, int index) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;ElementAt;(System.Collections.Generic.IEnumerable,System.Int32);;Argument[0].Element;ReturnValue;value;tb-generated public static TSource ElementAt(this IEnumerable source, int index) { throw null; } + public static IEnumerable Empty() { throw null; } + // These summaries will not be derivable based on type information. // public static IEnumerable ExceptBy(this IEnumerable first, IEnumerable second, Func keySelector) { throw null; } // public static IEnumerable Except(this IEnumerable first, IEnumerable second) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;FirstOrDefault;(System.Collections.Generic.IEnumerable);;Argument[0].Element;ReturnValue;value;tb-generated public static TSource? FirstOrDefault(this IEnumerable source) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;FirstOrDefault;(System.Collections.Generic.IEnumerable,TSource);;Argument[0].Element;ReturnValue;value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;FirstOrDefault;(System.Collections.Generic.IEnumerable,TSource);;Argument[1];ReturnValue;value;tb-generated public static TSource FirstOrDefault(this IEnumerable source, TSource defaultValue) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;FirstOrDefault;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;FirstOrDefault;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;ReturnValue;value;tb-generated public static TSource? FirstOrDefault(this IEnumerable source, Func predicate) { throw null; } + // Summary will not be correctly derivable based on type information. // public static TSource FirstOrDefault(this IEnumerable source, Func predicate, TSource defaultValue) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;First;(System.Collections.Generic.IEnumerable);;Argument[0].Element;ReturnValue;value;tb-generated public static TSource First(this IEnumerable source) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;First;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;First;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;ReturnValue;value;tb-generated public static TSource First(this IEnumerable source, Func predicate) { throw null; } + // Missing summary for Argument[0].Element -> Argument[2].Parameter[1].Element and similar problem for GroupJoin (issue with generator) // public static IEnumerable GroupBy(this IEnumerable source, Func keySelector, Func, TResult> resultSelector) { throw null; } // public static IEnumerable GroupJoin(this IEnumerable outer, IEnumerable inner, Func outerKeySelector, Func innerKeySelector, Func, TResult> resultSelector) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;IntersectBy;(System.Collections.Generic.IEnumerable,System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[2].Parameter[0];value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;IntersectBy;(System.Collections.Generic.IEnumerable,System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;ReturnValue.Element;value;tb-generated public static IEnumerable IntersectBy(this IEnumerable first, IEnumerable second, Func keySelector) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;Intersect;(System.Collections.Generic.IEnumerable,System.Collections.Generic.IEnumerable);;Argument[0].Element;ReturnValue.Element;value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;Intersect;(System.Collections.Generic.IEnumerable,System.Collections.Generic.IEnumerable);;Argument[1].Element;ReturnValue.Element;value;tb-generated public static IEnumerable Intersect(this IEnumerable first, IEnumerable second) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;Join;(System.Collections.Generic.IEnumerable,System.Collections.Generic.IEnumerable,System.Func,System.Func,System.Func);;Argument[0].Element;Argument[2].Parameter[0];value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;Join;(System.Collections.Generic.IEnumerable,System.Collections.Generic.IEnumerable,System.Func,System.Func,System.Func);;Argument[0].Element;Argument[4].Parameter[0];value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;Join;(System.Collections.Generic.IEnumerable,System.Collections.Generic.IEnumerable,System.Func,System.Func,System.Func);;Argument[1].Element;Argument[3].Parameter[0];value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;Join;(System.Collections.Generic.IEnumerable,System.Collections.Generic.IEnumerable,System.Func,System.Func,System.Func);;Argument[1].Element;Argument[4].Parameter[1];value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;Join;(System.Collections.Generic.IEnumerable,System.Collections.Generic.IEnumerable,System.Func,System.Func,System.Func);;Argument[4].ReturnValue;ReturnValue.Element;value;tb-generated public static IEnumerable Join(this IEnumerable outer, IEnumerable inner, Func outerKeySelector, Func innerKeySelector, Func resultSelector) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;LastOrDefault;(System.Collections.Generic.IEnumerable);;Argument[0].Element;ReturnValue;value;tb-generated public static TSource? LastOrDefault(this IEnumerable source) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;LastOrDefault;(System.Collections.Generic.IEnumerable,TSource);;Argument[0].Element;ReturnValue;value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;LastOrDefault;(System.Collections.Generic.IEnumerable,TSource);;Argument[1];ReturnValue;value;tb-generated public static TSource LastOrDefault(this IEnumerable source, TSource defaultValue) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;LastOrDefault;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;LastOrDefault;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;ReturnValue;value;tb-generated public static TSource? LastOrDefault(this IEnumerable source, Func predicate) { throw null; } + // Summary will not be correctly derivable based on type information (same problem as for FirstOrDefault) // public static TSource LastOrDefault(this IEnumerable source, Func predicate, TSource defaultValue) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;Last;(System.Collections.Generic.IEnumerable);;Argument[0].Element;ReturnValue;value;tb-generated public static TSource Last(this IEnumerable source) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;Last;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;Last;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;ReturnValue;value;tb-generated public static TSource Last(this IEnumerable source, Func predicate) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;LongCount;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated public static long LongCount(this IEnumerable source, Func predicate) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;MaxBy;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;MaxBy;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;ReturnValue;value;tb-generated public static TSource? MaxBy(this IEnumerable source, Func keySelector) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;Max;(System.Collections.Generic.IEnumerable);;Argument[0].Element;ReturnValue;value;tb-generated public static TSource? Max(this IEnumerable source) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;Max;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated public static decimal Max(this IEnumerable source, Func selector) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;Max;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;Max;(System.Collections.Generic.IEnumerable,System.Func);;Argument[1].ReturnValue;ReturnValue;value;tb-generated public static TResult? Max(this IEnumerable source, Func selector) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;MinBy;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;MinBy;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;ReturnValue;value;tb-generated public static TSource? MinBy(this IEnumerable source, Func keySelector) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;Min;(System.Collections.Generic.IEnumerable);;Argument[0].Element;ReturnValue;value;tb-generated public static TSource? Min(this IEnumerable source) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;Min;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;Min;(System.Collections.Generic.IEnumerable,System.Func);;Argument[1].ReturnValue;ReturnValue;value;tb-generated public static TResult? Min(this IEnumerable source, Func selector) { throw null; } + // These summaries will not be derivable based on type information. // public static IEnumerable OfType(this IEnumerable source) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;OrderByDescending;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;OrderByDescending;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;ReturnValue.Element;value;tb-generated public static IOrderedEnumerable OrderByDescending(this IEnumerable source, Func keySelector) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;OrderBy;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;OrderBy;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;ReturnValue.Element;value;tb-generated public static IOrderedEnumerable OrderBy(this IEnumerable source, Func keySelector) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;Prepend;(System.Collections.Generic.IEnumerable,TSource);;Argument[0].Element;ReturnValue.Element;value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;Prepend;(System.Collections.Generic.IEnumerable,TSource);;Argument[1];ReturnValue.Element;value;tb-generated public static IEnumerable Prepend(this IEnumerable source, TSource element) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;Repeat;(TResult,System.Int32);;Argument[0];ReturnValue.Element;value;tb-generated public static IEnumerable Repeat(TResult element, int count) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;Reverse;(System.Collections.Generic.IEnumerable);;Argument[0].Element;ReturnValue.Element;value;tb-generated public static IEnumerable Reverse(this IEnumerable source) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;SelectMany;(System.Collections.Generic.IEnumerable,System.Func>);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;SelectMany;(System.Collections.Generic.IEnumerable,System.Func>);;Argument[1].ReturnValue.Element;ReturnValue.Element;value;tb-generated public static IEnumerable SelectMany(this IEnumerable source, Func> selector) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;SelectMany;(System.Collections.Generic.IEnumerable,System.Func>,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;SelectMany;(System.Collections.Generic.IEnumerable,System.Func>,System.Func);;Argument[0].Element;Argument[2].Parameter[0];value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;SelectMany;(System.Collections.Generic.IEnumerable,System.Func>,System.Func);;Argument[1].ReturnValue.Element;Argument[2].Parameter[1];value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;SelectMany;(System.Collections.Generic.IEnumerable,System.Func>,System.Func);;Argument[2].ReturnValue;ReturnValue.Element;value;tb-generated public static IEnumerable SelectMany(this IEnumerable source, Func> collectionSelector, Func resultSelector) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;Select;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;Select;(System.Collections.Generic.IEnumerable,System.Func);;Argument[1].ReturnValue;ReturnValue.Element;value;tb-generated public static IEnumerable Select(this IEnumerable source, Func selector) { throw null; } + public static bool SequenceEqual(this IEnumerable first, IEnumerable second) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;SingleOrDefault;(System.Collections.Generic.IEnumerable);;Argument[0].Element;ReturnValue;value;tb-generated public static TSource? SingleOrDefault(this IEnumerable source) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;SingleOrDefault;(System.Collections.Generic.IEnumerable,TSource);;Argument[0].Element;ReturnValue;value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;SingleOrDefault;(System.Collections.Generic.IEnumerable,TSource);;Argument[1];ReturnValue;value;tb-generated public static TSource SingleOrDefault(this IEnumerable source, TSource defaultValue) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;SingleOrDefault;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;SingleOrDefault;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;ReturnValue;value;tb-generated public static TSource? SingleOrDefault(this IEnumerable source, Func predicate) { throw null; } + // Summary will not be correctly derivable based on type information (same problem as for FirstOrDefault) // public static TSource SingleOrDefault(this IEnumerable source, Func predicate, TSource defaultValue) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;Single;(System.Collections.Generic.IEnumerable);;Argument[0].Element;ReturnValue;value;tb-generated public static TSource Single(this IEnumerable source) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;Single;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;Single;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;ReturnValue;value;tb-generated public static TSource Single(this IEnumerable source, Func predicate) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;SkipLast;(System.Collections.Generic.IEnumerable,System.Int32);;Argument[0].Element;ReturnValue.Element;value;tb-generated public static IEnumerable SkipLast(this IEnumerable source, int count) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;SkipWhile;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;SkipWhile;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;ReturnValue.Element;value;tb-generated public static IEnumerable SkipWhile(this IEnumerable source, Func predicate) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;Skip;(System.Collections.Generic.IEnumerable,System.Int32);;Argument[0].Element;ReturnValue.Element;value;tb-generated public static IEnumerable Skip(this IEnumerable source, int count) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;TakeLast;(System.Collections.Generic.IEnumerable,System.Int32);;Argument[0].Element;ReturnValue.Element;value;tb-generated public static IEnumerable TakeLast(this IEnumerable source, int count) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;TakeWhile;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;TakeWhile;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;ReturnValue.Element;value;tb-generated public static IEnumerable TakeWhile(this IEnumerable source, Func predicate) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;Take;(System.Collections.Generic.IEnumerable,System.Int32);;Argument[0].Element;ReturnValue.Element;value;tb-generated public static IEnumerable Take(this IEnumerable source, int count) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;ThenByDescending;(Summaries.IOrderedEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;ThenByDescending;(Summaries.IOrderedEnumerable,System.Func);;Argument[0].Element;ReturnValue.Element;value;tb-generated public static IOrderedEnumerable ThenByDescending(this IOrderedEnumerable source, Func keySelector) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;ThenBy;(Summaries.IOrderedEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;ThenBy;(Summaries.IOrderedEnumerable,System.Func);;Argument[0].Element;ReturnValue.Element;value;tb-generated public static IOrderedEnumerable ThenBy(this IOrderedEnumerable source, Func keySelector) { throw null; } + // Missing summary for Argument[0].Element -> ReturnValue.Element (issue with generator) // public static TSource[] ToArray(this IEnumerable source) { throw null; } // Summaries related to dictionaries is not generated correctly as dictionaries are not identified as collections of keys and values (issue with generator). // public static Dictionary ToDictionary(this IEnumerable source, Func keySelector) where TKey : notnull { throw null; } // public static Dictionary ToDictionary(this IEnumerable source, Func keySelector, Func elementSelector) where TKey : notnull { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;ToHashSet;(System.Collections.Generic.IEnumerable);;Argument[0].Element;ReturnValue.Element;value;tb-generated public static HashSet ToHashSet(this IEnumerable source) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;ToList;(System.Collections.Generic.IEnumerable);;Argument[0].Element;ReturnValue.Element;value;tb-generated public static List ToList(this IEnumerable source) { throw null; } + // Type to complicated to be handled by the generator (issue with generator). // public static ILookup ToLookup(this IEnumerable source, Func keySelector) { throw null; } // public static ILookup ToLookup(this IEnumerable source, Func keySelector, Func elementSelector) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;UnionBy;(System.Collections.Generic.IEnumerable,System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[2].Parameter[0];value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;UnionBy;(System.Collections.Generic.IEnumerable,System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;ReturnValue.Element;value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;UnionBy;(System.Collections.Generic.IEnumerable,System.Collections.Generic.IEnumerable,System.Func);;Argument[1].Element;Argument[2].Parameter[0];value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;UnionBy;(System.Collections.Generic.IEnumerable,System.Collections.Generic.IEnumerable,System.Func);;Argument[1].Element;ReturnValue.Element;value;tb-generated public static IEnumerable UnionBy(this IEnumerable first, IEnumerable second, Func keySelector) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;Union;(System.Collections.Generic.IEnumerable,System.Collections.Generic.IEnumerable);;Argument[0].Element;ReturnValue.Element;value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;Union;(System.Collections.Generic.IEnumerable,System.Collections.Generic.IEnumerable);;Argument[1].Element;ReturnValue.Element;value;tb-generated public static IEnumerable Union(this IEnumerable first, IEnumerable second) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;Where;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[1].Parameter[0];value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;Where;(System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;ReturnValue.Element;value;tb-generated public static IEnumerable Where(this IEnumerable source, Func predicate) { throw null; } + // Type to complicated to be handled by the generator (issue with generator). // public static IEnumerable<(TFirst First, TSecond Second)> Zip(this IEnumerable first, IEnumerable second) { throw null; } // public static IEnumerable<(TFirst First, TSecond Second, TThird Third)> Zip(this IEnumerable first, IEnumerable second, IEnumerable third) { throw null; } + + // summary=Summaries;SystemLinqEnumerable;false;Zip;(System.Collections.Generic.IEnumerable,System.Collections.Generic.IEnumerable,System.Func);;Argument[0].Element;Argument[2].Parameter[0];value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;Zip;(System.Collections.Generic.IEnumerable,System.Collections.Generic.IEnumerable,System.Func);;Argument[1].Element;Argument[2].Parameter[1];value;tb-generated + // summary=Summaries;SystemLinqEnumerable;false;Zip;(System.Collections.Generic.IEnumerable,System.Collections.Generic.IEnumerable,System.Func);;Argument[2].ReturnValue;ReturnValue.Element;value;tb-generated public static IEnumerable Zip(this IEnumerable first, IEnumerable second, Func resultSelector) { throw null; } } -public interface IGrouping : IEnumerable, IEnumerable { +public interface IGrouping : IEnumerable, IEnumerable +{ + // summary=Summaries;IGrouping;true;get_Key;();;Argument[this].SyntheticField[ArgType0];ReturnValue;value;tb-generated TKey Key { get; } } @@ -195,7 +438,10 @@ public interface IGrouping : IEnumerable, IEnu // bool Contains(TKey key); // } -public interface IOrderedEnumerable : IEnumerable, IEnumerable { +public interface IOrderedEnumerable : IEnumerable, IEnumerable +{ + // summary=Summaries;IOrderedEnumerable;true;CreateOrderedEnumerable;(System.Func,System.Collections.Generic.IComparer,System.Boolean);;Argument[this].Element;Argument[0].Parameter[0];value;tb-generated + // summary=Summaries;IOrderedEnumerable;true;CreateOrderedEnumerable;(System.Func,System.Collections.Generic.IComparer,System.Boolean);;Argument[this].Element;ReturnValue.Element;value;tb-generated IOrderedEnumerable CreateOrderedEnumerable(Func keySelector, IComparer? comparer, bool descending); } diff --git a/java/ql/test/TestUtilities/InlineMadTest.qll b/java/ql/test/TestUtilities/InlineMadTest.qll index a336fa6b3a9a..91265466db5d 100644 --- a/java/ql/test/TestUtilities/InlineMadTest.qll +++ b/java/ql/test/TestUtilities/InlineMadTest.qll @@ -1,54 +1,5 @@ -import java as J - -private signature module InlineMadTestLangSig { - /** - * A base class of callables for modeling. - */ - class Callable; - - /** - * Gets a relevant code comment for `c`, if any. - */ - string getComment(Callable c); -} - -private module InlineMadTestImpl { - private class Callable = Lang::Callable; - - signature module InlineMadTestConfigSig { - /** - * Gets the kind of a captured model. - */ - string getKind(); - - /** - * Gets a captured model for `c`, if any. - */ - string getCapturedModel(Callable c); - } - - module InlineMadTest { - private string expects(Callable c) { - Lang::getComment(c).regexpCapture(" *(SPURIOUS-)?" + Input::getKind() + "=(.*)", 2) = result - } - - query predicate unexpectedModel(string msg) { - exists(Callable c, string flow | - flow = Input::getCapturedModel(c) and - not flow = expects(c) and - msg = "Unexpected " + Input::getKind() + " found: " + flow - ) - } - - query predicate expectedModel(string msg) { - exists(Callable c, string e | - e = expects(c) and - not e = Input::getCapturedModel(c) and - msg = "Expected " + Input::getKind() + " missing: " + e - ) - } - } -} +private import java as J +private import codeql.mad.test.InlineMadTest private module InlineMadTestLang implements InlineMadTestLangSig { class Callable = J::Callable; diff --git a/shared/mad/codeql/mad/test/InlineMadTest.qll b/shared/mad/codeql/mad/test/InlineMadTest.qll new file mode 100644 index 000000000000..4c292091d159 --- /dev/null +++ b/shared/mad/codeql/mad/test/InlineMadTest.qll @@ -0,0 +1,53 @@ +/** + * Provides some simple predicates for models as data related tests using + * inline expectations (as comments in the source code). + */ +signature module InlineMadTestLangSig { + /** + * A base class of callables for modeling. + */ + class Callable; + + /** + * Gets a relevant code comment for `c`, if any. + */ + string getComment(Callable c); +} + +module InlineMadTestImpl { + private class Callable = Lang::Callable; + + signature module InlineMadTestConfigSig { + /** + * Gets a captured model for `c`, if any. + */ + string getCapturedModel(Callable c); + + /** + * Gets the kind of a captured model. + */ + string getKind(); + } + + module InlineMadTest { + private string expects(Callable c) { + Lang::getComment(c).regexpCapture(" *(SPURIOUS-)?" + Input::getKind() + "=(.*)", 2) = result + } + + query predicate unexpectedModel(string msg) { + exists(Callable c, string flow | + flow = Input::getCapturedModel(c) and + not flow = expects(c) and + msg = "Unexpected " + Input::getKind() + " found: " + flow + ) + } + + query predicate expectedModel(string msg) { + exists(Callable c, string e | + e = expects(c) and + not e = Input::getCapturedModel(c) and + msg = "Expected " + Input::getKind() + " missing: " + e + ) + } + } +}