提交 d72c63aa 编写于 作者: C Cyrus Najmabadi

Use local functions

上级 5831fbda
......@@ -2693,8 +2693,7 @@ public override EnvDTE80.vsCMPropertyKind GetReadWrite(SyntaxNode memberNode)
{
Debug.Assert(memberNode is BasePropertyDeclarationSyntax);
var property = memberNode as BasePropertyDeclarationSyntax;
if (property == null)
if (!(memberNode is BasePropertyDeclarationSyntax property))
{
throw Exceptions.ThrowEFail();
}
......
......@@ -384,8 +384,7 @@ private bool TryGenerateCast(CastExpressionSyntax castExpression)
private bool TryGenerateNewClass(ObjectCreationExpressionSyntax objectCreationExpression)
{
var type = SemanticModel.GetSymbolInfo(objectCreationExpression.Type).Symbol as ITypeSymbol;
if (type == null)
if (!(SemanticModel.GetSymbolInfo(objectCreationExpression.Type).Symbol is ITypeSymbol type))
{
return false;
}
......
......@@ -3915,10 +3915,7 @@ public override SyntaxNode ValueReturningLambdaExpression(IEnumerable<SyntaxNode
}
private static bool IsSimpleLambdaParameter(SyntaxNode node)
{
var p = node as ParameterSyntax;
return p != null && p.Type == null && p.Default == null && p.Modifiers.Count == 0;
}
=> node is ParameterSyntax p && p.Type == null && p.Default == null && p.Modifiers.Count == 0;
public override SyntaxNode VoidReturningLambdaExpression(IEnumerable<SyntaxNode> lambdaParameters, SyntaxNode expression)
{
......
......@@ -1530,12 +1530,12 @@ public void TestUpdateDocumentsOrder()
var solution = CreateSolution();
var pid = ProjectId.CreateNewId();
Func<VersionStamp> GetVersion = () => solution.GetProject(pid).Version;
Func<ImmutableArray<DocumentId>> GetDocumentIds = () => solution.GetProject(pid).DocumentIds.ToImmutableArray();
Func<ImmutableArray<SyntaxTree>> GetSyntaxTrees = () =>
{
return solution.GetProject(pid).GetCompilationAsync().Result.SyntaxTrees.ToImmutableArray();
};
VersionStamp GetVersion() => solution.GetProject(pid).Version;
ImmutableArray<DocumentId> GetDocumentIds() => solution.GetProject(pid).DocumentIds.ToImmutableArray();
ImmutableArray<SyntaxTree> GetSyntaxTrees()
{
return solution.GetProject(pid).GetCompilationAsync().Result.SyntaxTrees.ToImmutableArray();
}
solution = solution.AddProject(pid, "test", "test.dll", LanguageNames.CSharp);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册