Skip to content

Commit f5cfd93

Browse files
committed
C#: Use pattern matching.
1 parent d687dd9 commit f5cfd93

File tree

1 file changed

+5
-16
lines changed
  • csharp/extractor/Semmle.Extraction.CSharp/Entities

1 file changed

+5
-16
lines changed

csharp/extractor/Semmle.Extraction.CSharp/Entities/Symbol.cs

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -118,23 +118,12 @@ public Handle? MetadataHandle
118118

119119
if (propertyInfo != null)
120120
{
121-
var value = propertyInfo.GetValue(symbol);
122-
123-
if (value is MethodDefinitionHandle)
124-
{
125-
return (MethodDefinitionHandle)value;
126-
}
127-
else if (value is TypeDefinitionHandle)
128-
{
129-
return (TypeDefinitionHandle)value;
130-
}
131-
else if (value is PropertyDefinitionHandle)
132-
{
133-
return (PropertyDefinitionHandle)value;
134-
}
135-
else if (value is FieldDefinitionHandle)
121+
switch (propertyInfo.GetValue(symbol))
136122
{
137-
return (FieldDefinitionHandle)value;
123+
case MethodDefinitionHandle md: return md;
124+
case TypeDefinitionHandle td: return td;
125+
case PropertyDefinitionHandle pd: return pd;
126+
case FieldDefinitionHandle fd: return fd;
138127
}
139128
}
140129

0 commit comments

Comments
 (0)