提交 768ee3be 编写于 作者: C CyrusNajmabadi

Use pattern switch

上级 0e1f1f9b
...@@ -865,28 +865,17 @@ public static DeclarationModifiers GetSymbolModifiers(this ISymbol symbol) ...@@ -865,28 +865,17 @@ public static DeclarationModifiers GetSymbolModifiers(this ISymbol symbol)
public static ITypeSymbol GetSymbolType(this ISymbol symbol) public static ITypeSymbol GetSymbolType(this ISymbol symbol)
{ {
if (symbol is ILocalSymbol localSymbol) switch (symbol)
{ {
case ILocalSymbol localSymbol:
return localSymbol.Type; return localSymbol.Type;
} case IFieldSymbol fieldSymbol:
if (symbol is IFieldSymbol fieldSymbol)
{
return fieldSymbol.Type; return fieldSymbol.Type;
} case IPropertySymbol propertySymbol:
if (symbol is IPropertySymbol propertySymbol)
{
return propertySymbol.Type; return propertySymbol.Type;
} case IParameterSymbol parameterSymbol:
if (symbol is IParameterSymbol parameterSymbol)
{
return parameterSymbol.Type; return parameterSymbol.Type;
} case IAliasSymbol aliasSymbol:
if (symbol is IAliasSymbol aliasSymbol)
{
return aliasSymbol.Target as ITypeSymbol; return aliasSymbol.Target as ITypeSymbol;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册