提交 67e0234f 编写于 作者: C CyrusNajmabadi

Use inline variables.

上级 361235cc
......@@ -132,8 +132,7 @@ internal static partial class ICodeDefinitionFactoryExtensions
{
// For non-out parameters, create a field and assign the parameter to it.
// TODO: I'm not sure that's what we really want for ref parameters.
string fieldName;
if (TryGetValue(parameterToNewFieldMap, parameterName, out fieldName))
if (TryGetValue(parameterToNewFieldMap, parameterName, out var fieldName))
{
yield return CodeGenerationSymbolFactory.CreateFieldSymbol(
attributes: null,
......@@ -157,8 +156,7 @@ private static bool TryGetValue(IDictionary<string, string> dictionary, string k
private static bool TryGetValue(IDictionary<string, ISymbol> dictionary, string key, out string value)
{
value = null;
ISymbol symbol;
if (dictionary != null && dictionary.TryGetValue(key, out symbol))
if (dictionary != null && dictionary.TryGetValue(key, out var symbol))
{
value = symbol.Name;
return true;
......@@ -193,8 +191,7 @@ private static bool TryGetValue(IDictionary<string, ISymbol> dictionary, string
{
// For non-out parameters, create a field and assign the parameter to it.
// TODO: I'm not sure that's what we really want for ref parameters.
string fieldName;
if (TryGetValue(parameterToExistingFieldMap, parameterName, out fieldName) ||
if (TryGetValue(parameterToExistingFieldMap, parameterName, out var fieldName) ||
TryGetValue(parameterToNewFieldMap, parameterName, out fieldName))
{
var fieldAccess = factory.MemberAccessExpression(factory.ThisExpression(), factory.IdentifierName(fieldName))
......
......@@ -31,8 +31,7 @@ public override ITypeSymbol DefaultVisit(ISymbol node)
private ITypeSymbol VisitType(ITypeSymbol symbol)
{
TType2 converted;
if (symbol is TType1 && _map.TryGetValue((TType1)symbol, out converted))
if (symbol is TType1 && _map.TryGetValue((TType1)symbol, out var converted))
{
return converted;
}
......
......@@ -434,17 +434,13 @@ public static bool OverlapsHiddenPosition(this SyntaxNode declaration, SyntaxNod
// should ensure that parent nodes are not processed in the same batch as child nodes.
if (previous == default(TextSpan) || !previous.IntersectsWith(span))
{
SyntaxNode currentNode;
SyntaxToken currentToken;
SyntaxTrivia currentTrivia;
if (nodesToReplace.TryGetValue(span, out currentNode))
if (nodesToReplace.TryGetValue(span, out var currentNode))
{
var original = (SyntaxNode)retryAnnotations.GetAnnotations(currentNode).SingleOrDefault() ?? currentNode;
var newNode = await computeReplacementNodeAsync(original, currentNode, cancellationToken).ConfigureAwait(false);
nodeReplacements[currentNode] = newNode;
}
else if (tokensToReplace.TryGetValue(span, out currentToken))
else if (tokensToReplace.TryGetValue(span, out var currentToken))
{
var original = (SyntaxToken)retryAnnotations.GetAnnotations(currentToken).SingleOrDefault();
if (original == default(SyntaxToken))
......@@ -455,7 +451,7 @@ public static bool OverlapsHiddenPosition(this SyntaxNode declaration, SyntaxNod
var newToken = await computeReplacementTokenAsync(original, currentToken, cancellationToken).ConfigureAwait(false);
tokenReplacements[currentToken] = newToken;
}
else if (triviaToReplace.TryGetValue(span, out currentTrivia))
else if (triviaToReplace.TryGetValue(span, out var currentTrivia))
{
var original = (SyntaxTrivia)retryAnnotations.GetAnnotations(currentTrivia).SingleOrDefault();
if (original == default(SyntaxTrivia))
......@@ -481,8 +477,7 @@ public static bool OverlapsHiddenPosition(this SyntaxNode declaration, SyntaxNod
nodes: nodesToReplace.Values,
computeReplacementNode: (original, rewritten) =>
{
SyntaxNode replaced;
if (rewritten != original || !nodeReplacements.TryGetValue(original, out replaced))
if (rewritten != original || !nodeReplacements.TryGetValue(original, out var replaced))
{
// the subtree did change, or we didn't have a replacement for it in this batch
// so we need to add an annotation so we can find this node again for the next batch.
......@@ -495,8 +490,7 @@ public static bool OverlapsHiddenPosition(this SyntaxNode declaration, SyntaxNod
tokens: tokensToReplace.Values,
computeReplacementToken: (original, rewritten) =>
{
SyntaxToken replaced;
if (rewritten != original || !tokenReplacements.TryGetValue(original, out replaced))
if (rewritten != original || !tokenReplacements.TryGetValue(original, out var replaced))
{
// the subtree did change, or we didn't have a replacement for it in this batch
// so we need to add an annotation so we can find this node again for the next batch.
......@@ -509,8 +503,7 @@ public static bool OverlapsHiddenPosition(this SyntaxNode declaration, SyntaxNod
trivia: triviaToReplace.Values,
computeReplacementTrivia: (original, rewritten) =>
{
SyntaxTrivia replaced;
if (!triviaReplacements.TryGetValue(original, out replaced))
if (!triviaReplacements.TryGetValue(original, out var replaced))
{
// the subtree did change, or we didn't have a replacement for it in this batch
// so we need to add an annotation so we can find this node again for the next batch.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册