diff --git a/csharp/extractor/Semmle.Extraction.CSharp/Entities/Constructor.cs b/csharp/extractor/Semmle.Extraction.CSharp/Entities/Constructor.cs index 14d9b5480151..3ab9caa5df48 100644 --- a/csharp/extractor/Semmle.Extraction.CSharp/Entities/Constructor.cs +++ b/csharp/extractor/Semmle.Extraction.CSharp/Entities/Constructor.cs @@ -22,6 +22,8 @@ private Constructor(Context cx, IMethodSymbol init) .ToList(); } + protected override IMethodSymbol BodyDeclaringSymbol => Symbol.PartialImplementationPart ?? Symbol; + public override void Populate(TextWriter trapFile) { PopulateMethod(trapFile); @@ -176,6 +178,14 @@ private void ExtractSourceInitializer(TextWriter trapFile, ITypeSymbol? type, IM init.PopulateArguments(trapFile, arguments, 0); } + private ConstructorDeclarationSyntax? OrdinaryConstructorSyntaxForLocation => + BodyDeclaringSymbol + .DeclaringSyntaxReferences + .Select(r => r.GetSyntax()) + .ToList() + .OfType() + .FirstOrDefault(); + private ConstructorDeclarationSyntax? OrdinaryConstructorSyntax => declaringReferenceSyntax .OfType() @@ -253,14 +263,14 @@ public override Microsoft.CodeAnalysis.Location? ReportingLocation { get { - if (OrdinaryConstructorSyntax is not null) + if (OrdinaryConstructorSyntaxForLocation is ConstructorDeclarationSyntax constructor) { - return OrdinaryConstructorSyntax.Identifier.GetLocation(); + return constructor.Identifier.GetLocation(); } - if (PrimaryConstructorSyntax is not null) + if (PrimaryConstructorSyntax is TypeDeclarationSyntax primary) { - return PrimaryConstructorSyntax.Identifier.GetLocation(); + return primary.Identifier.GetLocation(); } if (Symbol.IsImplicitlyDeclared) diff --git a/csharp/ql/test/library-tests/dataflow/constructors/ConstructorFlow.expected b/csharp/ql/test/library-tests/dataflow/constructors/ConstructorFlow.expected index 678dca279ff0..01cb14d3c25e 100644 --- a/csharp/ql/test/library-tests/dataflow/constructors/ConstructorFlow.expected +++ b/csharp/ql/test/library-tests/dataflow/constructors/ConstructorFlow.expected @@ -122,6 +122,22 @@ edges | Constructors.cs:143:29:143:30 | access to local variable o2 : Object | Constructors.cs:143:18:143:31 | object creation of type R1 : R1 [property Obj2] : Object | provenance | | | Constructors.cs:144:14:144:15 | access to local variable r1 : R1 [property Obj1] : Object | Constructors.cs:144:14:144:20 | access to property Obj1 | provenance | | | Constructors.cs:145:14:145:15 | access to local variable r1 : R1 [property Obj2] : Object | Constructors.cs:145:14:145:20 | access to property Obj2 | provenance | | +| Constructors.cs:152:40:152:40 | o : Object | Constructors.cs:157:52:157:52 | access to parameter o : Object | provenance | | +| Constructors.cs:152:40:152:40 | o : Object | Constructors.cs:157:52:157:52 | access to parameter o : Object | provenance | | +| Constructors.cs:157:40:157:40 | o : Object | Constructors.cs:157:52:157:52 | access to parameter o : Object | provenance | | +| Constructors.cs:157:40:157:40 | o : Object | Constructors.cs:157:52:157:52 | access to parameter o : Object | provenance | | +| Constructors.cs:157:46:157:48 | [post] this access : CPartial [property Obj] : Object | Constructors.cs:157:24:157:31 | this [Return] : CPartial [property Obj] : Object | provenance | | +| Constructors.cs:157:46:157:48 | [post] this access : CPartial [property Obj] : Object | Constructors.cs:157:24:157:31 | this [Return] : CPartial [property Obj] : Object | provenance | | +| Constructors.cs:157:52:157:52 | access to parameter o : Object | Constructors.cs:157:46:157:48 | [post] this access : CPartial [property Obj] : Object | provenance | | +| Constructors.cs:157:52:157:52 | access to parameter o : Object | Constructors.cs:157:46:157:48 | [post] this access : CPartial [property Obj] : Object | provenance | | +| Constructors.cs:162:13:162:13 | access to local variable o : Object | Constructors.cs:163:37:163:37 | access to local variable o : Object | provenance | | +| Constructors.cs:162:17:162:34 | call to method Source : Object | Constructors.cs:162:13:162:13 | access to local variable o : Object | provenance | | +| Constructors.cs:163:13:163:20 | access to local variable cPartial : CPartial [property Obj] : Object | Constructors.cs:164:14:164:21 | access to local variable cPartial : CPartial [property Obj] : Object | provenance | | +| Constructors.cs:163:24:163:38 | object creation of type CPartial : CPartial [property Obj] : Object | Constructors.cs:163:13:163:20 | access to local variable cPartial : CPartial [property Obj] : Object | provenance | | +| Constructors.cs:163:37:163:37 | access to local variable o : Object | Constructors.cs:152:40:152:40 | o : Object | provenance | | +| Constructors.cs:163:37:163:37 | access to local variable o : Object | Constructors.cs:157:40:157:40 | o : Object | provenance | | +| Constructors.cs:163:37:163:37 | access to local variable o : Object | Constructors.cs:163:24:163:38 | object creation of type CPartial : CPartial [property Obj] : Object | provenance | | +| Constructors.cs:164:14:164:21 | access to local variable cPartial : CPartial [property Obj] : Object | Constructors.cs:164:14:164:25 | access to property Obj | provenance | | nodes | Constructors.cs:3:18:3:26 | [post] this access : C_no_ctor [field s1] : Object | semmle.label | [post] this access : C_no_ctor [field s1] : Object | | Constructors.cs:5:24:5:25 | [post] this access : C_no_ctor [field s1] : Object | semmle.label | [post] this access : C_no_ctor [field s1] : Object | @@ -255,6 +271,20 @@ nodes | Constructors.cs:144:14:144:20 | access to property Obj1 | semmle.label | access to property Obj1 | | Constructors.cs:145:14:145:15 | access to local variable r1 : R1 [property Obj2] : Object | semmle.label | access to local variable r1 : R1 [property Obj2] : Object | | Constructors.cs:145:14:145:20 | access to property Obj2 | semmle.label | access to property Obj2 | +| Constructors.cs:152:40:152:40 | o : Object | semmle.label | o : Object | +| Constructors.cs:157:24:157:31 | this [Return] : CPartial [property Obj] : Object | semmle.label | this [Return] : CPartial [property Obj] : Object | +| Constructors.cs:157:40:157:40 | o : Object | semmle.label | o : Object | +| Constructors.cs:157:46:157:48 | [post] this access : CPartial [property Obj] : Object | semmle.label | [post] this access : CPartial [property Obj] : Object | +| Constructors.cs:157:46:157:48 | [post] this access : CPartial [property Obj] : Object | semmle.label | [post] this access : CPartial [property Obj] : Object | +| Constructors.cs:157:52:157:52 | access to parameter o : Object | semmle.label | access to parameter o : Object | +| Constructors.cs:157:52:157:52 | access to parameter o : Object | semmle.label | access to parameter o : Object | +| Constructors.cs:162:13:162:13 | access to local variable o : Object | semmle.label | access to local variable o : Object | +| Constructors.cs:162:17:162:34 | call to method Source : Object | semmle.label | call to method Source : Object | +| Constructors.cs:163:13:163:20 | access to local variable cPartial : CPartial [property Obj] : Object | semmle.label | access to local variable cPartial : CPartial [property Obj] : Object | +| Constructors.cs:163:24:163:38 | object creation of type CPartial : CPartial [property Obj] : Object | semmle.label | object creation of type CPartial : CPartial [property Obj] : Object | +| Constructors.cs:163:37:163:37 | access to local variable o : Object | semmle.label | access to local variable o : Object | +| Constructors.cs:164:14:164:21 | access to local variable cPartial : CPartial [property Obj] : Object | semmle.label | access to local variable cPartial : CPartial [property Obj] : Object | +| Constructors.cs:164:14:164:25 | access to property Obj | semmle.label | access to property Obj | subpaths | Constructors.cs:44:18:44:19 | this access : C2 [parameter o21param] : Object | Constructors.cs:46:23:46:27 | this access : C2 [parameter o21param] : Object | Constructors.cs:46:23:46:27 | [post] this access : C2 [field Obj21] : Object | Constructors.cs:44:18:44:19 | [post] this access : C2 [field Obj21] : Object | | Constructors.cs:64:37:64:37 | access to parameter o : Object | Constructors.cs:57:54:57:55 | o2 : Object | Constructors.cs:59:13:59:14 | access to parameter o1 : Object | Constructors.cs:64:27:64:34 | access to parameter o22param : Object | @@ -273,6 +303,8 @@ subpaths | Constructors.cs:132:29:132:30 | access to local variable o2 : Object | Constructors.cs:121:38:121:40 | oc2 : Object | Constructors.cs:121:16:121:17 | this [Return] : C4 [property Obj2] : Object | Constructors.cs:132:18:132:31 | object creation of type C4 : C4 [property Obj2] : Object | | Constructors.cs:143:25:143:26 | access to local variable o1 : Object | Constructors.cs:137:29:137:32 | Obj1 : Object | Constructors.cs:137:19:137:20 | this [Return] : R1 [property Obj1] : Object | Constructors.cs:143:18:143:31 | object creation of type R1 : R1 [property Obj1] : Object | | Constructors.cs:143:29:143:30 | access to local variable o2 : Object | Constructors.cs:137:42:137:45 | Obj2 : Object | Constructors.cs:137:19:137:20 | this [Return] : R1 [property Obj2] : Object | Constructors.cs:143:18:143:31 | object creation of type R1 : R1 [property Obj2] : Object | +| Constructors.cs:163:37:163:37 | access to local variable o : Object | Constructors.cs:152:40:152:40 | o : Object | Constructors.cs:157:24:157:31 | this [Return] : CPartial [property Obj] : Object | Constructors.cs:163:24:163:38 | object creation of type CPartial : CPartial [property Obj] : Object | +| Constructors.cs:163:37:163:37 | access to local variable o : Object | Constructors.cs:157:40:157:40 | o : Object | Constructors.cs:157:24:157:31 | this [Return] : CPartial [property Obj] : Object | Constructors.cs:163:24:163:38 | object creation of type CPartial : CPartial [property Obj] : Object | testFailures #select | Constructors.cs:15:18:15:19 | access to field s1 | Constructors.cs:5:29:5:45 | call to method Source : Object | Constructors.cs:15:18:15:19 | access to field s1 | $@ | Constructors.cs:5:29:5:45 | call to method Source : Object | call to method Source : Object | @@ -288,3 +320,4 @@ testFailures | Constructors.cs:134:14:134:20 | access to property Obj2 | Constructors.cs:131:18:131:34 | call to method Source : Object | Constructors.cs:134:14:134:20 | access to property Obj2 | $@ | Constructors.cs:131:18:131:34 | call to method Source : Object | call to method Source : Object | | Constructors.cs:144:14:144:20 | access to property Obj1 | Constructors.cs:141:18:141:34 | call to method Source : Object | Constructors.cs:144:14:144:20 | access to property Obj1 | $@ | Constructors.cs:141:18:141:34 | call to method Source : Object | call to method Source : Object | | Constructors.cs:145:14:145:20 | access to property Obj2 | Constructors.cs:142:18:142:35 | call to method Source : Object | Constructors.cs:145:14:145:20 | access to property Obj2 | $@ | Constructors.cs:142:18:142:35 | call to method Source : Object | call to method Source : Object | +| Constructors.cs:164:14:164:25 | access to property Obj | Constructors.cs:162:17:162:34 | call to method Source : Object | Constructors.cs:164:14:164:25 | access to property Obj | $@ | Constructors.cs:162:17:162:34 | call to method Source : Object | call to method Source : Object | diff --git a/csharp/ql/test/library-tests/dataflow/constructors/Constructors.cs b/csharp/ql/test/library-tests/dataflow/constructors/Constructors.cs index 9eae5079d847..94beb58544b3 100644 --- a/csharp/ql/test/library-tests/dataflow/constructors/Constructors.cs +++ b/csharp/ql/test/library-tests/dataflow/constructors/Constructors.cs @@ -145,6 +145,25 @@ public void M7() Sink(r1.Obj2); // $ hasValueFlow=10 } + public partial class CPartial + { + public object Obj { get; } + + public partial CPartial(object o); + } + + public partial class CPartial + { + public partial CPartial(object o) => Obj = o; + } + + public void M8() + { + var o = Source(11); + var cPartial = new CPartial(o); + Sink(cPartial.Obj); // $ hasValueFlow=11 + } + public static void Sink(object o) { } public static T Source(object source) => throw null; diff --git a/csharp/ql/test/library-tests/dispatch/CallGraph.expected b/csharp/ql/test/library-tests/dispatch/CallGraph.expected index 2feb959dd863..31e2a99ae24c 100644 --- a/csharp/ql/test/library-tests/dispatch/CallGraph.expected +++ b/csharp/ql/test/library-tests/dispatch/CallGraph.expected @@ -270,9 +270,10 @@ | ViableCallable.cs:679:17:679:20 | Run3 | ViableCallable.cs:637:21:637:21 | M | | ViableCallable.cs:679:17:679:20 | Run3 | ViableCallable.cs:646:21:646:21 | M | | ViableCallable.cs:679:17:679:20 | Run3 | ViableCallable.cs:648:21:648:21 | M | -| ViableCallable.cs:709:17:709:20 | Run1 | ViableCallable.cs:703:42:703:44 | get_Property | -| ViableCallable.cs:709:17:709:20 | Run1 | ViableCallable.cs:703:63:703:65 | set_Property | -| ViableCallable.cs:709:17:709:20 | Run1 | ViableCallable.cs:705:49:705:51 | get_Item | -| ViableCallable.cs:709:17:709:20 | Run1 | ViableCallable.cs:705:70:705:72 | set_Item | -| ViableCallable.cs:709:17:709:20 | Run1 | ViableCallable.cs:706:51:706:53 | add_Event | -| ViableCallable.cs:709:17:709:20 | Run1 | ViableCallable.cs:706:59:706:64 | remove_Event | +| ViableCallable.cs:711:17:711:20 | Run1 | ViableCallable.cs:704:24:704:31 | Partial1 | +| ViableCallable.cs:711:17:711:20 | Run1 | ViableCallable.cs:705:42:705:44 | get_Property | +| ViableCallable.cs:711:17:711:20 | Run1 | ViableCallable.cs:705:63:705:65 | set_Property | +| ViableCallable.cs:711:17:711:20 | Run1 | ViableCallable.cs:707:49:707:51 | get_Item | +| ViableCallable.cs:711:17:711:20 | Run1 | ViableCallable.cs:707:70:707:72 | set_Item | +| ViableCallable.cs:711:17:711:20 | Run1 | ViableCallable.cs:708:51:708:53 | add_Event | +| ViableCallable.cs:711:17:711:20 | Run1 | ViableCallable.cs:708:59:708:64 | remove_Event | diff --git a/csharp/ql/test/library-tests/dispatch/GetADynamicTarget.expected b/csharp/ql/test/library-tests/dispatch/GetADynamicTarget.expected index 5d6b4be4f878..84dc17b073aa 100644 --- a/csharp/ql/test/library-tests/dispatch/GetADynamicTarget.expected +++ b/csharp/ql/test/library-tests/dispatch/GetADynamicTarget.expected @@ -518,9 +518,10 @@ | ViableCallable.cs:683:9:683:16 | call to method M | C22+TestOverloadResolution2.M(Int32[]) | | ViableCallable.cs:687:9:687:16 | call to method M | C22+TestOverloadResolution1.M(List) | | ViableCallable.cs:687:9:687:16 | call to method M | C22+TestOverloadResolution2.M(List) | -| ViableCallable.cs:714:9:714:18 | access to property Property | C23+Partial1.set_Property(object) | -| ViableCallable.cs:717:13:717:22 | access to property Property | C23+Partial1.get_Property() | -| ViableCallable.cs:720:9:720:12 | access to indexer | C23+Partial1.set_Item(int, object) | -| ViableCallable.cs:723:13:723:16 | access to indexer | C23+Partial1.get_Item(int) | -| ViableCallable.cs:726:9:726:15 | access to event Event | C23+Partial1.add_Event(EventHandler) | -| ViableCallable.cs:729:9:729:15 | access to event Event | C23+Partial1.remove_Event(EventHandler) | +| ViableCallable.cs:716:9:716:18 | access to property Property | C23+Partial1.set_Property(object) | +| ViableCallable.cs:719:13:719:22 | access to property Property | C23+Partial1.get_Property() | +| ViableCallable.cs:722:9:722:12 | access to indexer | C23+Partial1.set_Item(int, object) | +| ViableCallable.cs:725:13:725:16 | access to indexer | C23+Partial1.get_Item(int) | +| ViableCallable.cs:728:9:728:15 | access to event Event | C23+Partial1.add_Event(EventHandler) | +| ViableCallable.cs:731:9:731:15 | access to event Event | C23+Partial1.remove_Event(EventHandler) | +| ViableCallable.cs:734:18:734:43 | object creation of type Partial1 | C23+Partial1.Partial1(object) | diff --git a/csharp/ql/test/library-tests/dispatch/ViableCallable.cs b/csharp/ql/test/library-tests/dispatch/ViableCallable.cs index e904eb01a862..dee8d9b0d1d6 100644 --- a/csharp/ql/test/library-tests/dispatch/ViableCallable.cs +++ b/csharp/ql/test/library-tests/dispatch/ViableCallable.cs @@ -692,6 +692,7 @@ public class C23 { public partial class Partial1 { + public partial Partial1(object obj); public partial object Property { get; set; } public partial object this[int index] { get; set; } @@ -700,6 +701,7 @@ public partial class Partial1 public partial class Partial1 { + public partial Partial1(object obj) { } public partial object Property { get { return null; } set { } } public partial object this[int index] { get { return null; } set { } } @@ -727,5 +729,8 @@ public void Run1(Partial1 p) // Viable callable: Partial1.remove_Event p.Event -= (sender, e) => { }; + + // Viable callable: Partial1.Partial1(object) + var p0 = new Partial1(new object()); } } diff --git a/csharp/ql/test/library-tests/partial/MethodIsPartial.expected b/csharp/ql/test/library-tests/partial/MethodIsPartial.expected index a0f1f88fb981..d2efe67a2c85 100644 --- a/csharp/ql/test/library-tests/partial/MethodIsPartial.expected +++ b/csharp/ql/test/library-tests/partial/MethodIsPartial.expected @@ -1,7 +1,7 @@ -| Partial.cs:6:18:6:42 | PartialMethodWithoutBody1 | true | -| Partial.cs:7:17:7:23 | Method2 | false | -| Partial.cs:18:18:18:39 | PartialMethodWithBody1 | true | -| Partial.cs:19:17:19:23 | Method3 | false | -| Partial.cs:41:18:41:42 | PartialMethodWithoutBody2 | true | -| Partial.cs:42:17:42:23 | Method4 | false | -| Partial.cs:47:17:47:23 | Method5 | false | +| Partial.cs:8:18:8:42 | PartialMethodWithoutBody1 | true | +| Partial.cs:9:17:9:23 | Method2 | false | +| Partial.cs:22:18:22:39 | PartialMethodWithBody1 | true | +| Partial.cs:23:17:23:23 | Method3 | false | +| Partial.cs:45:18:45:42 | PartialMethodWithoutBody2 | true | +| Partial.cs:46:17:46:23 | Method4 | false | +| Partial.cs:52:17:52:23 | Method5 | false | diff --git a/csharp/ql/test/library-tests/partial/Partial.cs b/csharp/ql/test/library-tests/partial/Partial.cs index 8dd757fcd24d..109d371cf291 100644 --- a/csharp/ql/test/library-tests/partial/Partial.cs +++ b/csharp/ql/test/library-tests/partial/Partial.cs @@ -2,6 +2,8 @@ partial class TwoPartClass { + // Declaring declaration. + public partial TwoPartClass(object obj); partial void PartialMethodWithBody1(); partial void PartialMethodWithoutBody1(); public void Method2() { } @@ -15,6 +17,8 @@ public void Method2() { } partial class TwoPartClass { + // Implementation declaration. + public partial TwoPartClass(object obj) { } partial void PartialMethodWithBody1() { } public void Method3() { } private object _backingField; @@ -44,6 +48,7 @@ public void Method4() { } class NonPartialClass { + public NonPartialClass(object obj) { } public void Method5() { } public object Property { get; set; } public object this[int index] diff --git a/csharp/ql/test/library-tests/partial/Partial1.expected b/csharp/ql/test/library-tests/partial/Partial1.expected index fe8f5658f48e..f47f04300a8a 100644 --- a/csharp/ql/test/library-tests/partial/Partial1.expected +++ b/csharp/ql/test/library-tests/partial/Partial1.expected @@ -1,17 +1,18 @@ | Partial.cs:3:15:3:26 | TwoPartClass | -| Partial.cs:6:18:6:42 | PartialMethodWithoutBody1 | -| Partial.cs:16:15:16:26 | TwoPartClass | -| Partial.cs:18:18:18:39 | PartialMethodWithBody1 | -| Partial.cs:22:27:22:42 | PartialProperty1 | -| Partial.cs:24:9:24:11 | get_PartialProperty1 | -| Partial.cs:25:9:25:11 | set_PartialProperty1 | -| Partial.cs:29:27:29:30 | Item | -| Partial.cs:31:9:31:11 | get_Item | -| Partial.cs:32:9:32:11 | set_Item | -| Partial.cs:36:39:36:51 | PartialEvent1 | -| Partial.cs:36:55:36:57 | add_PartialEvent1 | -| Partial.cs:36:63:36:68 | remove_PartialEvent1 | -| Partial.cs:39:15:39:33 | OnePartPartialClass | -| Partial.cs:41:18:41:42 | PartialMethodWithoutBody2 | +| Partial.cs:8:18:8:42 | PartialMethodWithoutBody1 | +| Partial.cs:18:15:18:26 | TwoPartClass | +| Partial.cs:21:20:21:31 | TwoPartClass | +| Partial.cs:22:18:22:39 | PartialMethodWithBody1 | +| Partial.cs:26:27:26:42 | PartialProperty1 | +| Partial.cs:28:9:28:11 | get_PartialProperty1 | +| Partial.cs:29:9:29:11 | set_PartialProperty1 | +| Partial.cs:33:27:33:30 | Item | +| Partial.cs:35:9:35:11 | get_Item | +| Partial.cs:36:9:36:11 | set_Item | +| Partial.cs:40:39:40:51 | PartialEvent1 | +| Partial.cs:40:55:40:57 | add_PartialEvent1 | +| Partial.cs:40:63:40:68 | remove_PartialEvent1 | +| Partial.cs:43:15:43:33 | OnePartPartialClass | +| Partial.cs:45:18:45:42 | PartialMethodWithoutBody2 | | PartialMultipleFiles1.cs:1:22:1:41 | PartialMultipleFiles | | PartialMultipleFiles2.cs:1:22:1:41 | PartialMultipleFiles | diff --git a/csharp/ql/test/library-tests/partial/Partial2.expected b/csharp/ql/test/library-tests/partial/Partial2.expected index 8d608c26011c..fce4ab07a747 100644 --- a/csharp/ql/test/library-tests/partial/Partial2.expected +++ b/csharp/ql/test/library-tests/partial/Partial2.expected @@ -1,15 +1,15 @@ | Partial.cs:3:15:3:26 | TwoPartClass | Partial.cs:3:15:3:26 | | -| Partial.cs:3:15:3:26 | TwoPartClass | Partial.cs:6:18:6:42 | PartialMethodWithoutBody1 | -| Partial.cs:3:15:3:26 | TwoPartClass | Partial.cs:7:17:7:23 | Method2 | -| Partial.cs:3:15:3:26 | TwoPartClass | Partial.cs:18:18:18:39 | PartialMethodWithBody1 | -| Partial.cs:3:15:3:26 | TwoPartClass | Partial.cs:19:17:19:23 | Method3 | -| Partial.cs:16:15:16:26 | TwoPartClass | Partial.cs:3:15:3:26 | | -| Partial.cs:16:15:16:26 | TwoPartClass | Partial.cs:6:18:6:42 | PartialMethodWithoutBody1 | -| Partial.cs:16:15:16:26 | TwoPartClass | Partial.cs:7:17:7:23 | Method2 | -| Partial.cs:16:15:16:26 | TwoPartClass | Partial.cs:18:18:18:39 | PartialMethodWithBody1 | -| Partial.cs:16:15:16:26 | TwoPartClass | Partial.cs:19:17:19:23 | Method3 | -| Partial.cs:39:15:39:33 | OnePartPartialClass | Partial.cs:39:15:39:33 | | -| Partial.cs:39:15:39:33 | OnePartPartialClass | Partial.cs:41:18:41:42 | PartialMethodWithoutBody2 | -| Partial.cs:39:15:39:33 | OnePartPartialClass | Partial.cs:42:17:42:23 | Method4 | +| Partial.cs:3:15:3:26 | TwoPartClass | Partial.cs:8:18:8:42 | PartialMethodWithoutBody1 | +| Partial.cs:3:15:3:26 | TwoPartClass | Partial.cs:9:17:9:23 | Method2 | +| Partial.cs:3:15:3:26 | TwoPartClass | Partial.cs:22:18:22:39 | PartialMethodWithBody1 | +| Partial.cs:3:15:3:26 | TwoPartClass | Partial.cs:23:17:23:23 | Method3 | +| Partial.cs:18:15:18:26 | TwoPartClass | Partial.cs:3:15:3:26 | | +| Partial.cs:18:15:18:26 | TwoPartClass | Partial.cs:8:18:8:42 | PartialMethodWithoutBody1 | +| Partial.cs:18:15:18:26 | TwoPartClass | Partial.cs:9:17:9:23 | Method2 | +| Partial.cs:18:15:18:26 | TwoPartClass | Partial.cs:22:18:22:39 | PartialMethodWithBody1 | +| Partial.cs:18:15:18:26 | TwoPartClass | Partial.cs:23:17:23:23 | Method3 | +| Partial.cs:43:15:43:33 | OnePartPartialClass | Partial.cs:43:15:43:33 | | +| Partial.cs:43:15:43:33 | OnePartPartialClass | Partial.cs:45:18:45:42 | PartialMethodWithoutBody2 | +| Partial.cs:43:15:43:33 | OnePartPartialClass | Partial.cs:46:17:46:23 | Method4 | | PartialMultipleFiles1.cs:1:22:1:41 | PartialMultipleFiles | PartialMultipleFiles1.cs:1:22:1:41 | | | PartialMultipleFiles2.cs:1:22:1:41 | PartialMultipleFiles | PartialMultipleFiles1.cs:1:22:1:41 | | diff --git a/csharp/ql/test/library-tests/partial/PartialAccessors.expected b/csharp/ql/test/library-tests/partial/PartialAccessors.expected index a9d70645420b..cbd7e91e70c8 100644 --- a/csharp/ql/test/library-tests/partial/PartialAccessors.expected +++ b/csharp/ql/test/library-tests/partial/PartialAccessors.expected @@ -1,12 +1,12 @@ -| Partial.cs:24:9:24:11 | get_PartialProperty1 | true | -| Partial.cs:25:9:25:11 | set_PartialProperty1 | true | -| Partial.cs:31:9:31:11 | get_Item | true | -| Partial.cs:32:9:32:11 | set_Item | true | -| Partial.cs:36:55:36:57 | add_PartialEvent1 | true | -| Partial.cs:36:63:36:68 | remove_PartialEvent1 | true | -| Partial.cs:48:30:48:32 | get_Property | false | -| Partial.cs:48:35:48:37 | set_Property | false | -| Partial.cs:51:9:51:11 | get_Item | false | -| Partial.cs:52:9:52:11 | set_Item | false | -| Partial.cs:54:31:54:35 | add_Event | false | -| Partial.cs:54:31:54:35 | remove_Event | false | +| Partial.cs:28:9:28:11 | get_PartialProperty1 | true | +| Partial.cs:29:9:29:11 | set_PartialProperty1 | true | +| Partial.cs:35:9:35:11 | get_Item | true | +| Partial.cs:36:9:36:11 | set_Item | true | +| Partial.cs:40:55:40:57 | add_PartialEvent1 | true | +| Partial.cs:40:63:40:68 | remove_PartialEvent1 | true | +| Partial.cs:53:30:53:32 | get_Property | false | +| Partial.cs:53:35:53:37 | set_Property | false | +| Partial.cs:56:9:56:11 | get_Item | false | +| Partial.cs:57:9:57:11 | set_Item | false | +| Partial.cs:59:31:59:35 | add_Event | false | +| Partial.cs:59:31:59:35 | remove_Event | false | diff --git a/csharp/ql/test/library-tests/partial/PartialConstructors.expected b/csharp/ql/test/library-tests/partial/PartialConstructors.expected index 69cabb244f53..a93b7dc9c497 100644 --- a/csharp/ql/test/library-tests/partial/PartialConstructors.expected +++ b/csharp/ql/test/library-tests/partial/PartialConstructors.expected @@ -1,4 +1,4 @@ -| Partial.cs:3:15:3:26 | TwoPartClass | Partial.cs:3:15:3:26 | {...} | -| Partial.cs:39:15:39:33 | OnePartPartialClass | Partial.cs:39:15:39:33 | {...} | -| Partial.cs:45:7:45:21 | NonPartialClass | Partial.cs:45:7:45:21 | {...} | +| Partial.cs:21:20:21:31 | TwoPartClass | Partial.cs:21:45:21:47 | {...} | +| Partial.cs:43:15:43:33 | OnePartPartialClass | Partial.cs:43:15:43:33 | {...} | +| Partial.cs:51:12:51:26 | NonPartialClass | Partial.cs:51:40:51:42 | {...} | | PartialMultipleFiles1.cs:1:22:1:41 | PartialMultipleFiles | PartialMultipleFiles1.cs:1:22:1:41 | {...} | diff --git a/csharp/ql/test/library-tests/partial/PartialEvents.expected b/csharp/ql/test/library-tests/partial/PartialEvents.expected index b12f8a07a9df..5eff3d23f805 100644 --- a/csharp/ql/test/library-tests/partial/PartialEvents.expected +++ b/csharp/ql/test/library-tests/partial/PartialEvents.expected @@ -1,2 +1,2 @@ -| Partial.cs:36:39:36:51 | PartialEvent1 | true | -| Partial.cs:54:31:54:35 | Event | false | +| Partial.cs:40:39:40:51 | PartialEvent1 | true | +| Partial.cs:59:31:59:35 | Event | false | diff --git a/csharp/ql/test/library-tests/partial/PartialIndexers.expected b/csharp/ql/test/library-tests/partial/PartialIndexers.expected index be625fc4ad51..95fd7ae7df2e 100644 --- a/csharp/ql/test/library-tests/partial/PartialIndexers.expected +++ b/csharp/ql/test/library-tests/partial/PartialIndexers.expected @@ -1,2 +1,2 @@ -| Partial.cs:29:27:29:30 | Item | true | -| Partial.cs:49:19:49:22 | Item | false | +| Partial.cs:33:27:33:30 | Item | true | +| Partial.cs:54:19:54:22 | Item | false | diff --git a/csharp/ql/test/library-tests/partial/PartialMethodBody.expected b/csharp/ql/test/library-tests/partial/PartialMethodBody.expected index a91a156cb627..e9102ed35668 100644 --- a/csharp/ql/test/library-tests/partial/PartialMethodBody.expected +++ b/csharp/ql/test/library-tests/partial/PartialMethodBody.expected @@ -1,3 +1,3 @@ -| Partial.cs:6:18:6:42 | PartialMethodWithoutBody1 | false | -| Partial.cs:18:18:18:39 | PartialMethodWithBody1 | true | -| Partial.cs:41:18:41:42 | PartialMethodWithoutBody2 | false | +| Partial.cs:8:18:8:42 | PartialMethodWithoutBody1 | false | +| Partial.cs:22:18:22:39 | PartialMethodWithBody1 | true | +| Partial.cs:45:18:45:42 | PartialMethodWithoutBody2 | false | diff --git a/csharp/ql/test/library-tests/partial/PartialProperties.expected b/csharp/ql/test/library-tests/partial/PartialProperties.expected index 4686bbf087a4..0bb23d385f41 100644 --- a/csharp/ql/test/library-tests/partial/PartialProperties.expected +++ b/csharp/ql/test/library-tests/partial/PartialProperties.expected @@ -1,2 +1,2 @@ -| Partial.cs:22:27:22:42 | PartialProperty1 | true | -| Partial.cs:48:19:48:26 | Property | false | +| Partial.cs:26:27:26:42 | PartialProperty1 | true | +| Partial.cs:53:19:53:26 | Property | false | diff --git a/csharp/ql/test/library-tests/partial/PrintAst.expected b/csharp/ql/test/library-tests/partial/PrintAst.expected index 315de869fb3d..bcb787f7f1c0 100644 --- a/csharp/ql/test/library-tests/partial/PrintAst.expected +++ b/csharp/ql/test/library-tests/partial/PrintAst.expected @@ -1,112 +1,122 @@ Partial.cs: # 3| [Class] TwoPartClass -# 6| 6: [Method] PartialMethodWithoutBody1 -# 6| -1: [TypeMention] Void -# 7| 7: [Method] Method2 +# 8| 5: [Method] PartialMethodWithoutBody1 +# 8| -1: [TypeMention] Void +# 9| 6: [Method] Method2 +# 9| -1: [TypeMention] Void +# 9| 4: [BlockStmt] {...} +# 21| 7: [InstanceConstructor] TwoPartClass +#-----| 2: (Parameters) +# 6| 0: [Parameter] obj +# 6| -1: [TypeMention] object +# 21| 4: [BlockStmt] {...} +# 22| 8: [Method] PartialMethodWithBody1 # 7| -1: [TypeMention] Void -# 7| 4: [BlockStmt] {...} -# 18| 8: [Method] PartialMethodWithBody1 -# 5| -1: [TypeMention] Void -# 18| 4: [BlockStmt] {...} -# 19| 9: [Method] Method3 -# 19| -1: [TypeMention] Void -# 19| 4: [BlockStmt] {...} -# 20| 10: [Field] _backingField -# 20| -1: [TypeMention] object -# 22| 11: [Property] PartialProperty1 -# 9| -1: [TypeMention] object -# 22| -1: [TypeMention] object -# 24| 3: [Getter] get_PartialProperty1 -# 24| 4: [BlockStmt] {...} -# 24| 0: [ReturnStmt] return ...; -# 24| 0: [FieldAccess] access to field _backingField -# 25| 4: [Setter] set_PartialProperty1 -#-----| 2: (Parameters) -# 25| 0: [Parameter] value -# 25| 4: [BlockStmt] {...} -# 25| 0: [ExprStmt] ...; -# 25| 0: [AssignExpr] ... = ... -# 25| 0: [FieldAccess] access to field _backingField -# 25| 1: [ParameterAccess] access to parameter value -# 27| 12: [Field] _backingArray -# 27| -1: [TypeMention] Object[] -# 27| 1: [TypeMention] object -# 29| 13: [Indexer] Item +# 22| 4: [BlockStmt] {...} +# 23| 9: [Method] Method3 +# 23| -1: [TypeMention] Void +# 23| 4: [BlockStmt] {...} +# 24| 10: [Field] _backingField +# 24| -1: [TypeMention] object +# 26| 11: [Property] PartialProperty1 # 11| -1: [TypeMention] object -# 29| -1: [TypeMention] object -#-----| 1: (Parameters) -# 11| 0: [Parameter] index -# 11| -1: [TypeMention] int -# 29| -1: [TypeMention] int -# 31| 3: [Getter] get_Item +# 26| -1: [TypeMention] object +# 28| 3: [Getter] get_PartialProperty1 +# 28| 4: [BlockStmt] {...} +# 28| 0: [ReturnStmt] return ...; +# 28| 0: [FieldAccess] access to field _backingField +# 29| 4: [Setter] set_PartialProperty1 #-----| 2: (Parameters) -# 29| 0: [Parameter] index -# 31| 4: [BlockStmt] {...} -# 31| 0: [ReturnStmt] return ...; -# 31| 0: [ArrayAccess] access to array element -# 31| -1: [FieldAccess] access to field _backingArray -# 31| 0: [ParameterAccess] access to parameter index -# 32| 4: [Setter] set_Item +# 29| 0: [Parameter] value +# 29| 4: [BlockStmt] {...} +# 29| 0: [ExprStmt] ...; +# 29| 0: [AssignExpr] ... = ... +# 29| 0: [FieldAccess] access to field _backingField +# 29| 1: [ParameterAccess] access to parameter value +# 31| 12: [Field] _backingArray +# 31| -1: [TypeMention] Object[] +# 31| 1: [TypeMention] object +# 33| 13: [Indexer] Item +# 13| -1: [TypeMention] object +# 33| -1: [TypeMention] object +#-----| 1: (Parameters) +# 13| 0: [Parameter] index +# 13| -1: [TypeMention] int +# 33| -1: [TypeMention] int +# 35| 3: [Getter] get_Item #-----| 2: (Parameters) -# 29| 0: [Parameter] index -# 32| 1: [Parameter] value -# 32| 4: [BlockStmt] {...} -# 32| 0: [ExprStmt] ...; -# 32| 0: [AssignExpr] ... = ... -# 32| 0: [ArrayAccess] access to array element -# 32| -1: [FieldAccess] access to field _backingArray -# 32| 0: [ParameterAccess] access to parameter index -# 32| 1: [ParameterAccess] access to parameter value -# 36| 14: [Event] PartialEvent1 -# 13| -1: [TypeMention] EventHandler -# 36| 3: [AddEventAccessor] add_PartialEvent1 +# 33| 0: [Parameter] index +# 35| 4: [BlockStmt] {...} +# 35| 0: [ReturnStmt] return ...; +# 35| 0: [ArrayAccess] access to array element +# 35| -1: [FieldAccess] access to field _backingArray +# 35| 0: [ParameterAccess] access to parameter index +# 36| 4: [Setter] set_Item #-----| 2: (Parameters) -# 36| 0: [Parameter] value +# 33| 0: [Parameter] index +# 36| 1: [Parameter] value # 36| 4: [BlockStmt] {...} -# 36| 4: [RemoveEventAccessor] remove_PartialEvent1 +# 36| 0: [ExprStmt] ...; +# 36| 0: [AssignExpr] ... = ... +# 36| 0: [ArrayAccess] access to array element +# 36| -1: [FieldAccess] access to field _backingArray +# 36| 0: [ParameterAccess] access to parameter index +# 36| 1: [ParameterAccess] access to parameter value +# 40| 14: [Event] PartialEvent1 +# 15| -1: [TypeMention] EventHandler +# 40| 3: [AddEventAccessor] add_PartialEvent1 #-----| 2: (Parameters) -# 36| 0: [Parameter] value -# 36| 4: [BlockStmt] {...} -# 39| [Class] OnePartPartialClass -# 41| 6: [Method] PartialMethodWithoutBody2 -# 41| -1: [TypeMention] Void -# 42| 7: [Method] Method4 -# 42| -1: [TypeMention] Void -# 42| 4: [BlockStmt] {...} -# 45| [Class] NonPartialClass -# 47| 6: [Method] Method5 -# 47| -1: [TypeMention] Void -# 47| 4: [BlockStmt] {...} -# 48| 7: [Property] Property -# 48| -1: [TypeMention] object -# 48| 3: [Getter] get_Property -# 48| 4: [Setter] set_Property +# 40| 0: [Parameter] value +# 40| 4: [BlockStmt] {...} +# 40| 4: [RemoveEventAccessor] remove_PartialEvent1 +#-----| 2: (Parameters) +# 40| 0: [Parameter] value +# 40| 4: [BlockStmt] {...} +# 43| [Class] OnePartPartialClass +# 45| 6: [Method] PartialMethodWithoutBody2 +# 45| -1: [TypeMention] Void +# 46| 7: [Method] Method4 +# 46| -1: [TypeMention] Void +# 46| 4: [BlockStmt] {...} +# 49| [Class] NonPartialClass +# 51| 5: [InstanceConstructor] NonPartialClass +#-----| 2: (Parameters) +# 51| 0: [Parameter] obj +# 51| -1: [TypeMention] object +# 51| 4: [BlockStmt] {...} +# 52| 6: [Method] Method5 +# 52| -1: [TypeMention] Void +# 52| 4: [BlockStmt] {...} +# 53| 7: [Property] Property +# 53| -1: [TypeMention] object +# 53| 3: [Getter] get_Property +# 53| 4: [Setter] set_Property #-----| 2: (Parameters) -# 48| 0: [Parameter] value -# 49| 8: [Indexer] Item -# 49| -1: [TypeMention] object +# 53| 0: [Parameter] value +# 54| 8: [Indexer] Item +# 54| -1: [TypeMention] object #-----| 1: (Parameters) -# 49| 0: [Parameter] index -# 49| -1: [TypeMention] int -# 51| 3: [Getter] get_Item +# 54| 0: [Parameter] index +# 54| -1: [TypeMention] int +# 56| 3: [Getter] get_Item #-----| 2: (Parameters) -# 49| 0: [Parameter] index -# 51| 4: [BlockStmt] {...} -# 51| 0: [ReturnStmt] return ...; -# 51| 0: [NullLiteral] null -# 52| 4: [Setter] set_Item +# 54| 0: [Parameter] index +# 56| 4: [BlockStmt] {...} +# 56| 0: [ReturnStmt] return ...; +# 56| 0: [NullLiteral] null +# 57| 4: [Setter] set_Item #-----| 2: (Parameters) -# 49| 0: [Parameter] index -# 52| 1: [Parameter] value -# 52| 4: [BlockStmt] {...} -# 54| 9: [Event] Event -# 54| -1: [TypeMention] EventHandler -# 54| 3: [AddEventAccessor] add_Event +# 54| 0: [Parameter] index +# 57| 1: [Parameter] value +# 57| 4: [BlockStmt] {...} +# 59| 9: [Event] Event +# 59| -1: [TypeMention] EventHandler +# 59| 3: [AddEventAccessor] add_Event #-----| 2: (Parameters) -# 54| 0: [Parameter] value -# 54| 4: [RemoveEventAccessor] remove_Event +# 59| 0: [Parameter] value +# 59| 4: [RemoveEventAccessor] remove_Event #-----| 2: (Parameters) -# 54| 0: [Parameter] value +# 59| 0: [Parameter] value PartialMultipleFiles1.cs: # 1| [Class] PartialMultipleFiles PartialMultipleFiles2.cs: