Merge pull request #18348 from michaelnebel/csharp/locktype

C# 13: [TEST ONLY] Add test using the System.Threading.Lock type.
This commit is contained in:
Michael Nebel
2025-01-03 15:08:46 +01:00
committed by GitHub
49 changed files with 737 additions and 699 deletions

View File

@@ -1 +1 @@
| statements.cs:10:21:10:24 | Main |
| statements.cs:11:21:11:24 | Main |

View File

@@ -1 +1 @@
| statements.cs:146:21:146:29 | MainBreak | statements.cs:151:32:151:37 | break; |
| statements.cs:147:21:147:29 | MainBreak | statements.cs:152:32:152:37 | break; |

View File

@@ -1 +1 @@
| statements.cs:233:13:236:13 | checked {...} | statements.cs:234:13:236:13 | {...} |
| statements.cs:234:13:237:13 | checked {...} | statements.cs:235:13:237:13 | {...} |

View File

@@ -1,3 +1,3 @@
| fixed.cs:3:7:3:11 | {...} | fixed.cs:3:7:3:11 | Fixed |
| statements.cs:7:11:7:15 | {...} | statements.cs:7:11:7:15 | Class |
| statements.cs:243:15:243:25 | {...} | statements.cs:243:15:243:25 | AccountLock |
| statements.cs:8:11:8:15 | {...} | statements.cs:8:11:8:15 | Class |
| statements.cs:244:15:244:25 | {...} | statements.cs:244:15:244:25 | AccountLock |

View File

@@ -1 +1 @@
| statements.cs:156:21:156:32 | MainContinue | statements.cs:160:46:160:54 | continue; |
| statements.cs:157:21:157:32 | MainContinue | statements.cs:161:46:161:54 | continue; |

View File

@@ -1 +1 @@
| statements.cs:120:21:120:26 | MainDo | statements.cs:123:13:127:32 | do ... while (...); |
| statements.cs:121:21:121:26 | MainDo | statements.cs:124:13:128:32 | do ... while (...); |

View File

@@ -1 +1 @@
| statements.cs:47:21:47:28 | MainExpr |
| statements.cs:48:21:48:28 | MainExpr |

View File

@@ -1 +1 @@
| statements.cs:132:13:135:13 | for (...;...;...) ... | statements.cs:132:29:132:43 | ... < ... |
| statements.cs:133:13:136:13 | for (...;...;...) ... | statements.cs:133:29:133:43 | ... < ... |

View File

@@ -1 +1 @@
| statements.cs:132:13:135:13 | for (...;...;...) ... | statements.cs:132:46:132:48 | ...++ |
| statements.cs:133:13:136:13 | for (...;...;...) ... | statements.cs:133:46:133:48 | ...++ |

View File

@@ -1 +1 @@
| statements.cs:132:13:135:13 | for (...;...;...) ... | statements.cs:132:22:132:26 | Int32 i = ... |
| statements.cs:133:13:136:13 | for (...;...;...) ... | statements.cs:133:22:133:26 | Int32 i = ... |

View File

@@ -1 +1 @@
| statements.cs:138:21:138:31 | MainForeach |
| statements.cs:139:21:139:31 | MainForeach |

View File

@@ -1 +1 @@
| statements.cs:140:13:143:13 | foreach (... ... in ...) ... | statements.cs:140:29:140:29 | s |
| statements.cs:141:13:144:13 | foreach (... ... in ...) ... | statements.cs:141:29:141:29 | s |

View File

@@ -1 +1 @@
| statements.cs:165:21:165:28 | MainGoto | statements.cs:168:13:168:23 | goto ...; |
| statements.cs:166:21:166:28 | MainGoto | statements.cs:169:13:169:23 | goto ...; |

View File

@@ -1 +1 @@
| statements.cs:165:21:165:28 | MainGoto | statements.cs:170:41:170:50 | goto ...; |
| statements.cs:166:21:166:28 | MainGoto | statements.cs:171:37:171:46 | goto ...; |

View File

@@ -1 +1 @@
| statements.cs:58:13:65:13 | if (...) ... | statements.cs:63:13:65:13 | {...} |
| statements.cs:59:13:66:13 | if (...) ... | statements.cs:64:13:66:13 | {...} |

View File

@@ -1 +1 @@
| statements.cs:272:21:272:31 | MainLabeled | statements.cs:275:13:275:17 | Label: |
| statements.cs:273:21:273:31 | MainLabeled | statements.cs:276:9:276:13 | Label: |

View File

@@ -1 +1 @@
| statements.cs:40:21:40:38 | MainLocalConstDecl | statements.cs:42:13:42:40 | const ... ...; | statements.cs:42:25:42:39 | Single pi = ... | 3.1415927 |
| statements.cs:41:21:41:38 | MainLocalConstDecl | statements.cs:43:13:43:40 | const ... ...; | statements.cs:43:25:43:39 | Single pi = ... | 3.1415927 |

View File

@@ -1 +1 @@
| statements.cs:40:21:40:38 | MainLocalConstDecl | statements.cs:43:13:43:33 | const ... ...; | statements.cs:43:23:43:32 | Int32 r = ... |
| statements.cs:41:21:41:38 | MainLocalConstDecl | statements.cs:44:13:44:33 | const ... ...; | statements.cs:44:23:44:32 | Int32 r = ... |

View File

@@ -1 +1 @@
| statements.cs:40:21:40:38 | MainLocalConstDecl | statements.cs:43:13:43:33 | const ... ...; | statements.cs:43:23:43:32 | Int32 r = ... |
| statements.cs:41:21:41:38 | MainLocalConstDecl | statements.cs:44:13:44:33 | const ... ...; | statements.cs:44:23:44:32 | Int32 r = ... |

View File

@@ -1 +1 @@
| statements.cs:30:21:30:36 | MainLocalVarDecl | statements.cs:32:13:32:18 | ... ...; | statements.cs:32:17:32:17 | Int32 a |
| statements.cs:31:21:31:36 | MainLocalVarDecl | statements.cs:33:13:33:18 | ... ...; | statements.cs:33:17:33:17 | Int32 a |

View File

@@ -1 +1 @@
| statements.cs:30:21:30:36 | MainLocalVarDecl | statements.cs:33:13:33:29 | ... ...; | statements.cs:33:17:33:21 | Int32 b = ... |
| statements.cs:31:21:31:36 | MainLocalVarDecl | statements.cs:34:13:34:29 | ... ...; | statements.cs:34:17:34:21 | Int32 b = ... |

View File

@@ -1 +1 @@
| statements.cs:30:21:30:36 | MainLocalVarDecl | statements.cs:33:13:33:29 | ... ...; | statements.cs:33:17:33:21 | Int32 b = ... | statements.cs:33:24:33:28 | Int32 c = ... |
| statements.cs:31:21:31:36 | MainLocalVarDecl | statements.cs:34:13:34:29 | ... ...; | statements.cs:34:17:34:21 | Int32 b = ... | statements.cs:34:24:34:28 | Int32 c = ... |

View File

@@ -1 +1 @@
| statements.cs:30:21:30:36 | MainLocalVarDecl | statements.cs:32:13:32:18 | ... ...; | statements.cs:32:17:32:17 | Int32 a |
| statements.cs:31:21:31:36 | MainLocalVarDecl | statements.cs:33:13:33:18 | ... ...; | statements.cs:33:17:33:17 | Int32 a |

View File

@@ -1 +1 @@
| statements.cs:30:21:30:36 | MainLocalVarDecl | statements.cs:37:13:37:27 | ... ...; | statements.cs:37:17:37:26 | String y = ... |
| statements.cs:31:21:31:36 | MainLocalVarDecl | statements.cs:38:13:38:27 | ... ...; | statements.cs:38:17:38:26 | String y = ... |

View File

@@ -1 +1 @@
| statements.cs:248:17:255:17 | lock (...) {...} | statements.cs:248:23:248:26 | this access | statements.cs:249:17:255:17 | {...} |
| statements.cs:249:17:256:17 | lock (...) {...} | statements.cs:249:23:249:26 | this access | statements.cs:250:17:256:17 | {...} |

View File

@@ -0,0 +1 @@
| statements.cs:285:13:288:13 | lock (...) {...} | statements.cs:285:19:285:28 | access to field lockObject | Lock | statements.cs:286:13:288:13 | {...} |

View File

@@ -0,0 +1,8 @@
import csharp
from Method m, LockStmt ls, Expr lockExpr
where
ls.getEnclosingCallable() = m and
m.getName() = "LockMethod" and
lockExpr = ls.getExpr()
select ls, lockExpr, lockExpr.getType().toString(), ls.getBlock()

File diff suppressed because it is too large Load Diff

View File

@@ -1 +1 @@
| statements.cs:177:21:177:30 | MainReturn | statements.cs:180:13:180:19 | return ...; |
| statements.cs:178:21:178:30 | MainReturn | statements.cs:181:13:181:19 | return ...; |

View File

@@ -1 +1 @@
| statements.cs:173:20:173:22 | Add | statements.cs:175:13:175:25 | return ...; | statements.cs:175:20:175:24 | ... + ... |
| statements.cs:174:20:174:22 | Add | statements.cs:176:13:176:25 | return ...; | statements.cs:176:20:176:24 | ... + ... |

View File

@@ -1,23 +1,25 @@
| statements.cs:16:17:19:17 | {...} | statements.cs:17:21:18:21 | {...} |
| statements.cs:57:9:66:9 | {...} | statements.cs:58:13:65:13 | if (...) ... |
| statements.cs:59:13:61:13 | {...} | statements.cs:60:17:60:50 | ...; |
| statements.cs:63:13:65:13 | {...} | statements.cs:64:17:64:59 | ...; |
| statements.cs:131:9:136:9 | {...} | statements.cs:132:13:135:13 | for (...;...;...) ... |
| statements.cs:133:13:135:13 | {...} | statements.cs:134:17:134:43 | ...; |
| statements.cs:139:9:144:9 | {...} | statements.cs:140:13:143:13 | foreach (... ... in ...) ... |
| statements.cs:141:13:143:13 | {...} | statements.cs:142:17:142:37 | ...; |
| statements.cs:147:9:154:9 | {...} | statements.cs:148:13:153:13 | while (...) ... |
| statements.cs:157:9:163:9 | {...} | statements.cs:158:13:162:13 | for (...;...;...) ... |
| statements.cs:174:9:176:9 | {...} | statements.cs:175:13:175:25 | return ...; |
| statements.cs:186:13:188:13 | {...} | statements.cs:187:17:187:31 | yield return ...; |
| statements.cs:192:9:197:9 | {...} | statements.cs:193:13:196:13 | foreach (... ... in ...) ... |
| statements.cs:194:13:196:13 | {...} | statements.cs:195:17:195:37 | ...; |
| statements.cs:205:9:228:9 | {...} | statements.cs:206:13:227:13 | try {...} ... |
| statements.cs:209:17:211:17 | {...} | statements.cs:210:21:210:64 | throw ...; |
| statements.cs:217:13:219:13 | {...} | statements.cs:218:17:218:45 | ...; |
| statements.cs:221:13:223:13 | {...} | statements.cs:222:17:222:47 | ...; |
| statements.cs:225:13:227:13 | {...} | statements.cs:226:17:226:47 | ...; |
| statements.cs:234:13:236:13 | {...} | statements.cs:235:17:235:41 | ...; |
| statements.cs:238:13:240:13 | {...} | statements.cs:239:17:239:41 | ...; |
| statements.cs:247:13:256:13 | {...} | statements.cs:248:17:255:17 | lock (...) {...} |
| statements.cs:251:21:253:21 | {...} | statements.cs:252:25:252:66 | throw ...; |
| statements.cs:17:17:20:17 | {...} | statements.cs:18:21:19:21 | {...} |
| statements.cs:58:9:67:9 | {...} | statements.cs:59:13:66:13 | if (...) ... |
| statements.cs:60:13:62:13 | {...} | statements.cs:61:17:61:50 | ...; |
| statements.cs:64:13:66:13 | {...} | statements.cs:65:17:65:59 | ...; |
| statements.cs:132:9:137:9 | {...} | statements.cs:133:13:136:13 | for (...;...;...) ... |
| statements.cs:134:13:136:13 | {...} | statements.cs:135:17:135:43 | ...; |
| statements.cs:140:9:145:9 | {...} | statements.cs:141:13:144:13 | foreach (... ... in ...) ... |
| statements.cs:142:13:144:13 | {...} | statements.cs:143:17:143:37 | ...; |
| statements.cs:148:9:155:9 | {...} | statements.cs:149:13:154:13 | while (...) ... |
| statements.cs:158:9:164:9 | {...} | statements.cs:159:13:163:13 | for (...;...;...) ... |
| statements.cs:175:9:177:9 | {...} | statements.cs:176:13:176:25 | return ...; |
| statements.cs:187:13:189:13 | {...} | statements.cs:188:17:188:31 | yield return ...; |
| statements.cs:193:9:198:9 | {...} | statements.cs:194:13:197:13 | foreach (... ... in ...) ... |
| statements.cs:195:13:197:13 | {...} | statements.cs:196:17:196:37 | ...; |
| statements.cs:206:9:229:9 | {...} | statements.cs:207:13:228:13 | try {...} ... |
| statements.cs:210:17:212:17 | {...} | statements.cs:211:21:211:64 | throw ...; |
| statements.cs:218:13:220:13 | {...} | statements.cs:219:17:219:45 | ...; |
| statements.cs:222:13:224:13 | {...} | statements.cs:223:17:223:47 | ...; |
| statements.cs:226:13:228:13 | {...} | statements.cs:227:17:227:47 | ...; |
| statements.cs:235:13:237:13 | {...} | statements.cs:236:17:236:41 | ...; |
| statements.cs:239:13:241:13 | {...} | statements.cs:240:17:240:41 | ...; |
| statements.cs:248:13:257:13 | {...} | statements.cs:249:17:256:17 | lock (...) {...} |
| statements.cs:252:21:254:21 | {...} | statements.cs:253:25:253:66 | throw ...; |
| statements.cs:284:9:289:9 | {...} | statements.cs:285:13:288:13 | lock (...) {...} |
| statements.cs:286:13:288:13 | {...} | statements.cs:287:17:287:44 | ...; |

View File

@@ -1,2 +1,2 @@
| statements.cs:71:13:82:13 | switch (...) {...} | statements.cs:71:21:71:21 | access to local variable n | 2 | 1 | 9 |
| statements.cs:87:13:106:13 | switch (...) {...} | statements.cs:87:21:87:23 | access to parameter foo | 9 | 0 | 17 |
| statements.cs:72:13:83:13 | switch (...) {...} | statements.cs:72:21:72:21 | access to local variable n | 2 | 1 | 9 |
| statements.cs:88:13:107:13 | switch (...) {...} | statements.cs:88:21:88:23 | access to parameter foo | 9 | 0 | 17 |

View File

@@ -1,11 +1,11 @@
| statements.cs:68:21:68:30 | MainSwitch | statements.cs:73:17:73:23 | case ...: | 73 |
| statements.cs:68:21:68:30 | MainSwitch | statements.cs:76:17:76:23 | case ...: | 76 |
| statements.cs:85:20:85:31 | StringSwitch | statements.cs:89:17:89:29 | case ...: | 89 |
| statements.cs:85:20:85:31 | StringSwitch | statements.cs:91:17:91:27 | case ...: | 91 |
| statements.cs:85:20:85:31 | StringSwitch | statements.cs:93:17:93:29 | case ...: | 93 |
| statements.cs:85:20:85:31 | StringSwitch | statements.cs:95:17:95:30 | case ...: | 95 |
| statements.cs:85:20:85:31 | StringSwitch | statements.cs:97:17:97:28 | case ...: | 97 |
| statements.cs:85:20:85:31 | StringSwitch | statements.cs:99:17:99:31 | case ...: | 99 |
| statements.cs:85:20:85:31 | StringSwitch | statements.cs:101:17:101:28 | case ...: | 101 |
| statements.cs:85:20:85:31 | StringSwitch | statements.cs:103:17:103:28 | case ...: | 103 |
| statements.cs:85:20:85:31 | StringSwitch | statements.cs:104:17:104:29 | case ...: | 104 |
| statements.cs:69:21:69:30 | MainSwitch | statements.cs:74:17:74:23 | case ...: | 74 |
| statements.cs:69:21:69:30 | MainSwitch | statements.cs:77:17:77:23 | case ...: | 77 |
| statements.cs:86:20:86:31 | StringSwitch | statements.cs:90:17:90:29 | case ...: | 90 |
| statements.cs:86:20:86:31 | StringSwitch | statements.cs:92:17:92:27 | case ...: | 92 |
| statements.cs:86:20:86:31 | StringSwitch | statements.cs:94:17:94:29 | case ...: | 94 |
| statements.cs:86:20:86:31 | StringSwitch | statements.cs:96:17:96:30 | case ...: | 96 |
| statements.cs:86:20:86:31 | StringSwitch | statements.cs:98:17:98:28 | case ...: | 98 |
| statements.cs:86:20:86:31 | StringSwitch | statements.cs:100:17:100:31 | case ...: | 100 |
| statements.cs:86:20:86:31 | StringSwitch | statements.cs:102:17:102:28 | case ...: | 102 |
| statements.cs:86:20:86:31 | StringSwitch | statements.cs:104:17:104:28 | case ...: | 104 |
| statements.cs:86:20:86:31 | StringSwitch | statements.cs:105:17:105:29 | case ...: | 105 |

View File

@@ -1 +1 @@
| statements.cs:68:21:68:30 | MainSwitch | statements.cs:79:17:79:24 | default: | 79 |
| statements.cs:69:21:69:30 | MainSwitch | statements.cs:80:17:80:24 | default: | 80 |

View File

@@ -1 +1,2 @@
| statements.cs:245:21:245:27 | balance |
| statements.cs:246:21:246:27 | balance |
| statements.cs:281:31:281:40 | lockObject |

View File

@@ -1 +1 @@
| 1 | statements.cs:201:31:201:57 | object creation of type DivideByZeroException |
| 1 | statements.cs:202:31:202:57 | object creation of type DivideByZeroException |

View File

@@ -1,2 +1,2 @@
| statements.cs:206:13:227:13 | try {...} ... | statements.cs:216:13:219:13 | catch (...) {...} |
| statements.cs:206:13:227:13 | try {...} ... | statements.cs:220:13:223:13 | catch {...} |
| statements.cs:207:13:228:13 | try {...} ... | statements.cs:217:13:220:13 | catch (...) {...} |
| statements.cs:207:13:228:13 | try {...} ... | statements.cs:221:13:224:13 | catch {...} |

View File

@@ -1,2 +1,2 @@
| statements.cs:206:13:227:13 | try {...} ... | statements.cs:216:13:219:13 | catch (...) {...} |
| statements.cs:206:13:227:13 | try {...} ... | statements.cs:220:13:223:13 | catch {...} |
| statements.cs:207:13:228:13 | try {...} ... | statements.cs:217:13:220:13 | catch (...) {...} |
| statements.cs:207:13:228:13 | try {...} ... | statements.cs:221:13:224:13 | catch {...} |

View File

@@ -1 +1 @@
| statements.cs:216:13:219:13 | catch (...) {...} | Exception |
| statements.cs:217:13:220:13 | catch (...) {...} | Exception |

View File

@@ -1 +1 @@
| statements.cs:216:13:219:13 | catch (...) {...} | Exception |
| statements.cs:217:13:220:13 | catch (...) {...} | Exception |

View File

@@ -1 +1 @@
| statements.cs:216:30:216:30 | e | statements.cs:218:35:218:35 | access to local variable e |
| statements.cs:217:30:217:30 | e | statements.cs:219:35:219:35 | access to local variable e |

View File

@@ -1 +1 @@
| statements.cs:204:21:204:32 | MainTryThrow |
| statements.cs:205:21:205:32 | MainTryThrow |

View File

@@ -1 +1 @@
| statements.cs:220:13:223:13 | catch {...} | Exception |
| statements.cs:221:13:224:13 | catch {...} | Exception |

View File

@@ -1 +1 @@
| statements.cs:225:13:227:13 | {...} |
| statements.cs:226:13:228:13 | {...} |

View File

@@ -1 +1 @@
| statements.cs:237:13:240:13 | unchecked {...} | statements.cs:238:13:240:13 | {...} |
| statements.cs:238:13:241:13 | unchecked {...} | statements.cs:239:13:241:13 | {...} |

View File

@@ -1 +1 @@
| statements.cs:259:21:259:29 | MainUsing |
| statements.cs:260:21:260:29 | MainUsing |

View File

@@ -1 +1 @@
| statements.cs:259:21:259:29 | MainUsing | statements.cs:261:31:261:31 | w |
| statements.cs:260:21:260:29 | MainUsing | statements.cs:262:31:262:31 | w |

View File

@@ -1 +1 @@
| statements.cs:110:21:110:29 | MainWhile | statements.cs:113:13:117:13 | while (...) ... |
| statements.cs:111:21:111:29 | MainWhile | statements.cs:114:13:118:13 | while (...) ... |

View File

@@ -1,6 +1,7 @@
using System;
using System.IO;
using System.Collections.Generic;
using System.Threading;
namespace Statements
{
@@ -9,7 +10,7 @@ namespace Statements
static void Main()
{
block:
block:
{
{
}
@@ -166,8 +167,8 @@ namespace Statements
{
int i = 0;
goto check;
loop: Console.WriteLine(args[i++]);
check: if (i < args.Length) goto loop;
loop: Console.WriteLine(args[i++]);
check: if (i < args.Length) goto loop;
}
static int Add(int a, int b)
@@ -272,9 +273,19 @@ namespace Statements
static void MainLabeled()
{
goto Label;
Label:
Label:
int x = 23;
x = 9;
}
private readonly Lock lockObject = new Lock();
public void LockMethod()
{
lock (lockObject)
{
Console.WriteLine("Locked");
}
}
}
}