File tree Expand file tree Collapse file tree
test/library-tests/cil/init-only-prop Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -246,6 +246,9 @@ class Setter extends Accessor {
246246 Setter ( ) { cil_setter ( _, this ) }
247247
248248 override Property getProperty ( ) { cil_setter ( result , this ) }
249+
250+ /** Holds if this setter is an `init`-only accessor. */
251+ predicate isInitOnly ( ) { none ( ) }
249252}
250253
251254/**
Original file line number Diff line number Diff line change 1+ // semmle-extractor-options: --cil
2+
3+ using System ;
4+
5+ class Test
6+ {
7+ static void Main ( string [ ] args )
8+ {
9+ }
10+ }
Original file line number Diff line number Diff line change 1+ namespace System.Runtime.CompilerServices
2+ {
3+ class IsExternalInit { }
4+ }
5+
6+ namespace cil_init_prop
7+ {
8+ class SomeClass
9+ {
10+ public int Prop1 { get; set; }
11+ public int Prop2 { get; init; }
12+ }
13+ }
Original file line number Diff line number Diff line change 1+ | cil-init-prop.dll:0:0:0:0 | set_Prop1 | set |
2+ | cil-init-prop.dll:0:0:0:0 | set_Prop2 | set |
Original file line number Diff line number Diff line change 1+ import semmle.code.cil.Method
2+ import semmle.code.csharp.Location
3+
4+ private string getType ( Setter s ) { if s .isInitOnly ( ) then result = "init" else result = "set" }
5+
6+ from Setter s
7+ where s .getLocation ( ) .( Assembly ) .getName ( ) = "cil-init-prop"
8+ select s , getType ( s )
You can’t perform that action at this time.
0 commit comments