* A C# parameter's type: past its attributes and the modifiers that are no * part of it (`this`, `params`, `scoped`), keeping `ref`, `out` and `in`, * which are, and before its name and default value.
(param: string)
| 281 | * which are, and before its name and default value. |
| 282 | */ |
| 283 | function csharpParameterType(param: string): string | null { |
| 284 | let p = param.trim(); |
| 285 | while (p.startsWith('[')) { |
| 286 | const close = closingBracket(p, 0); |
| 287 | if (close < 0) return null; |
| 288 | p = p.slice(close + 1).trim(); |
| 289 | } |
| 290 | const assign = topLevelIndex(p, (i) => p[i] === '=' && !/[=!<>]/.test(p[i - 1] ?? '') && !/[=>]/.test(p[i + 1] ?? '')); |
| 291 | if (assign >= 0) p = p.slice(0, assign).trim(); |
| 292 | const m = /^([\s\S]*?\S)\s+@?[A-Za-z_]\w*$/.exec(p); |
| 293 | if (!m) return null; |
| 294 | let type = m[1]!.trim(); |
| 295 | const kept: string[] = []; |
| 296 | for (let mod = /^(this|params|scoped|ref|out|in|readonly)\s+/.exec(type); mod; mod = /^(this|params|scoped|ref|out|in|readonly)\s+/.exec(type)) { |
| 297 | if (mod[1] !== 'this' && mod[1] !== 'params' && mod[1] !== 'scoped') kept.push(mod[1]!); |
| 298 | type = type.slice(mod[0].length); |
| 299 | } |
| 300 | return type ? [...kept, type].join(' ') : null; |
| 301 | } |
| 302 | |
| 303 | /** |
| 304 | * A parameter type as the languages compare it: qualifiers dropped |
no test coverage detected