本文整理汇总了C#中AssignmentExpressionSyntax类的典型用法代码示例。如果您正苦于以下问题:C# AssignmentExpressionSyntax类的具体用法?C# AssignmentExpressionSyntax怎么用?C# AssignmentExpressionSyntax使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AssignmentExpressionSyntax类属于命名空间,在下文中一共展示了AssignmentExpressionSyntax类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: VisitAssignmentExpression
/// <summary>
/// Normalizes the <paramref name="assignment" />.
/// </summary>
public override SyntaxNode VisitAssignmentExpression(AssignmentExpressionSyntax assignment)
{
if (!IsFormulaType(assignment.Left) || IsFormulaType(assignment.Right))
return base.VisitAssignmentExpression(assignment);
return assignment.WithRight(CreateInvocation(assignment.Right));
}
开发者ID:isse-augsburg,项目名称:ssharp,代码行数:10,代码来源:FormulaNormalizer.cs
示例2: AnalyzeOwnershipInAssignment
/// <summary>
/// Analyzes the ownership of the given-up symbol
/// in the assignment expression.
/// </summary>
/// <param name="givenUpSymbol">GivenUpOwnershipSymbol</param>
/// <param name="assignment">AssignmentExpressionSyntax</param>
/// <param name="statement">Statement</param>
/// <param name="machine">StateMachine</param>
/// <param name="model">SemanticModel</param>
/// <param name="trace">TraceInfo</param>
protected override void AnalyzeOwnershipInAssignment(GivenUpOwnershipSymbol givenUpSymbol,
AssignmentExpressionSyntax assignment, Statement statement, StateMachine machine,
SemanticModel model, TraceInfo trace)
{
var leftIdentifier = base.AnalysisContext.GetRootIdentifier(assignment.Left);
ISymbol leftSymbol = model.GetSymbolInfo(leftIdentifier).Symbol;
if (assignment.Right is IdentifierNameSyntax)
{
var rightIdentifier = base.AnalysisContext.GetRootIdentifier(assignment.Right);
ISymbol rightSymbol = model.GetSymbolInfo(rightIdentifier).Symbol;
if (statement.Summary.DataFlowAnalysis.FlowsIntoSymbol(rightSymbol,
givenUpSymbol.ContainingSymbol, statement, givenUpSymbol.Statement))
{
var type = model.GetTypeInfo(assignment.Right).Type;
if (leftSymbol != null && leftSymbol.Kind == SymbolKind.Field &&
base.IsFieldAccessedInSuccessor(leftSymbol as IFieldSymbol, statement.Summary, machine) &&
!base.AnalysisContext.IsTypePassedByValueOrImmutable(type))
{
TraceInfo newTrace = new TraceInfo();
newTrace.Merge(trace);
newTrace.AddErrorTrace(statement.SyntaxNode);
AnalysisErrorReporter.ReportGivenUpOwnershipFieldAssignment(newTrace, leftSymbol);
}
return;
}
}
else if (assignment.Right is MemberAccessExpressionSyntax)
{
this.AnalyzeOwnershipInExpression(givenUpSymbol, assignment.Right, statement,
machine, model, trace);
}
else if (assignment.Right is InvocationExpressionSyntax ||
assignment.Right is ObjectCreationExpressionSyntax)
{
trace.InsertCall(statement.Summary.Method, assignment.Right);
base.AnalyzeOwnershipInCall(givenUpSymbol, assignment.Right, statement,
machine, model, trace);
}
if (assignment.Left is MemberAccessExpressionSyntax)
{
ISymbol outerLeftMemberSymbol = model.GetSymbolInfo(assignment.Left).Symbol;
if (!outerLeftMemberSymbol.Equals(leftSymbol) &&
statement.Summary.DataFlowAnalysis.FlowsIntoSymbol(givenUpSymbol.ContainingSymbol,
leftSymbol, givenUpSymbol.Statement, statement))
{
TraceInfo newTrace = new TraceInfo();
newTrace.Merge(trace);
newTrace.AddErrorTrace(statement.SyntaxNode);
AnalysisErrorReporter.ReportGivenUpOwnershipAccess(newTrace);
}
}
}
开发者ID:yonglehou,项目名称:PSharp,代码行数:68,代码来源:RespectsOwnershipAnalysisPass.cs
示例3: BindDeconstructionAssignment
private BoundExpression BindDeconstructionAssignment(AssignmentExpressionSyntax node, DiagnosticBag diagnostics)
{
var left = (TupleExpressionSyntax)node.Left;
ArrayBuilder<DeconstructionVariable> checkedVariables = BindDeconstructionAssignmentVariables(left.Arguments, left, diagnostics);
var result = BindDeconstructionAssignment(node, node.Right, checkedVariables, diagnostics, isDeclaration: false);
FreeDeconstructionVariables(checkedVariables);
return result;
}
开发者ID:xeronith,项目名称:roslyn,代码行数:10,代码来源:Binder_Deconstruct.cs
示例4: ParseIfStatement
internal static bool ParseIfStatement(IfStatementSyntax node, out ExpressionSyntax condition, out ExpressionSyntax target, out AssignmentExpressionSyntax whenTrue, out AssignmentExpressionSyntax whenFalse)
{
condition = null;
target = null;
whenTrue = null;
whenFalse = null;
if (node == null || node.Else == null || node.Parent is IfStatementSyntax || node.Else.Statement is IfStatementSyntax)
return false;
condition = node.Condition;
//make sure to check for multiple statements
ExpressionStatementSyntax whenTrueExprStatement, whenFalseExprStatement;
var embeddedBlock = node.Statement as BlockSyntax;
if (embeddedBlock != null)
{
if (embeddedBlock.Statements.Count > 1)
return false;
var childNodes = embeddedBlock.ChildNodes();
if (childNodes.Count() > 1)
return false;
whenTrueExprStatement = childNodes.OfType<ExpressionStatementSyntax>().FirstOrDefault();
}
else
{
whenTrueExprStatement = node.Statement as ExpressionStatementSyntax;
}
var elseBlock = node.Else.Statement as BlockSyntax;
if (elseBlock != null)
{
if (elseBlock.Statements.Count > 1)
return false;
var childNodes = elseBlock.ChildNodes();
if (childNodes.Count() > 1)
return false;
whenFalseExprStatement = childNodes.OfType<ExpressionStatementSyntax>().FirstOrDefault();
}
else
{
whenFalseExprStatement = node.Else.Statement as ExpressionStatementSyntax;
}
if (whenTrueExprStatement == null || whenFalseExprStatement == null)
return false;
whenTrue = whenTrueExprStatement.Expression as AssignmentExpressionSyntax;
whenFalse = whenFalseExprStatement.Expression as AssignmentExpressionSyntax;
if (whenTrue == null || whenFalse == null || whenTrue.Kind() != whenFalse.Kind() ||
!SyntaxFactory.AreEquivalent(whenTrue.Left, whenFalse.Left))
return false;
return true;
}
开发者ID:alecor191,项目名称:RefactoringEssentials,代码行数:54,代码来源:ConvertIfStatementToConditionalTernaryExpressionCodeRefactoringProvider.cs
示例5: VisitAssignmentExpression
public override void VisitAssignmentExpression(AssignmentExpressionSyntax node)
{
cb.AppendIndent();
Visit(node.Left);
cb.Append(" = ");
Visit(node.Right);
cb.AppendLine(";");
}
开发者ID:ActiveMesa,项目名称:Blackmire,代码行数:11,代码来源:CppImplWalker.cs
示例6: AnalyzeOwnershipInAssignment
/// <summary>
/// Analyzes the ownership of the given-up symbol
/// in the assignment expression.
/// </summary>
/// <param name="givenUpSymbol">GivenUpOwnershipSymbol</param>
/// <param name="assignment">AssignmentExpressionSyntax</param>
/// <param name="statement">Statement</param>
/// <param name="machine">StateMachine</param>
/// <param name="model">SemanticModel</param>
/// <param name="trace">TraceInfo</param>
protected override void AnalyzeOwnershipInAssignment(GivenUpOwnershipSymbol givenUpSymbol,
AssignmentExpressionSyntax assignment, Statement statement, StateMachine machine,
SemanticModel model, TraceInfo trace)
{
IdentifierNameSyntax leftIdentifier = base.AnalysisContext.GetRootIdentifier(assignment.Left);
ISymbol leftSymbol = model.GetSymbolInfo(leftIdentifier).Symbol;
this.AnalyzeGivingUpFieldOwnership(givenUpSymbol, leftSymbol, statement, machine, trace);
this.AnalyzeOwnershipInExpression(givenUpSymbol, assignment.Right,
statement, machine, model, trace);
}
开发者ID:yonglehou,项目名称:PSharp,代码行数:21,代码来源:GivesUpOwnershipAnalysisPass.cs
示例7: ReplaceAddExpressionByStringBuilderAppendExpression
private static SyntaxNode ReplaceAddExpressionByStringBuilderAppendExpression(AssignmentExpressionSyntax assignmentExpression, SyntaxNode expressionStatement, SyntaxNode expressionStatementParent, string builderName)
{
var appendExpressionOnLoop = assignmentExpression.IsKind(SyntaxKind.SimpleAssignmentExpression)
? SyntaxFactory.ParseStatement($"{builderName}.Append({((BinaryExpressionSyntax)assignmentExpression.Right).Right.ToString()});\r\n")
: SyntaxFactory.ParseStatement($"{builderName}.Append({assignmentExpression.Right.ToString()});\r\n");
appendExpressionOnLoop = appendExpressionOnLoop
.WithLeadingTrivia(expressionStatement.GetLeadingTrivia())
.WithTrailingTrivia(expressionStatement.GetTrailingTrivia());
var newExpressionStatementParent = expressionStatementParent.ReplaceNode(expressionStatement, appendExpressionOnLoop);
return newExpressionStatementParent;
}
开发者ID:haroldhues,项目名称:code-cracker,代码行数:11,代码来源:StringBuilderInLoopCodeFixProvider.cs
示例8: IsAssignmentOutsideConstructor
private static bool IsAssignmentOutsideConstructor(AssignmentExpressionSyntax assignment, ISymbol fieldSymbol, SemanticModel model)
{
var assignedSymbol = model.GetSymbolInfo(assignment.Left);
if (assignedSymbol.Symbol != fieldSymbol)
{
return false;
}
// Method (or whatever) enclosing the assignment
var enclosingSymbol = model.GetEnclosingSymbol(assignment.SpanStart) as IMethodSymbol;
var isCtor = enclosingSymbol?.MethodKind == MethodKind.Constructor;
return !isCtor;
}
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:12,代码来源:ReadWriteForEfficiencyDiagnosticAnalyzer.cs
示例9: CheckConditionAndAssignment
static bool CheckConditionAndAssignment(SyntaxNodeAnalysisContext nodeContext, AssignmentExpressionSyntax assignment, BinaryExpressionSyntax condition)
{
if (assignment == null)
return false;
var assignmentTarget = nodeContext.SemanticModel.GetSymbolInfo(assignment.Left).Symbol;
if (assignmentTarget == null)
return false;
var condLeftSymbol = nodeContext.SemanticModel.GetSymbolInfo(condition.Left).Symbol;
var condRightSymbol = nodeContext.SemanticModel.GetSymbolInfo(condition.Right).Symbol;
var assignmentValue = nodeContext.SemanticModel.GetSymbolInfo(assignment.Right).Symbol;
var constant = nodeContext.SemanticModel.GetConstantValue(assignment.Right);
bool constantAssignment = assignmentValue == null && constant.HasValue;
if (assignmentTarget.Equals(condLeftSymbol))
{
if (constantAssignment)
{
var condRightValue = nodeContext.SemanticModel.GetConstantValue(condition.Right);
if (condRightValue.HasValue)
return condRightValue.Value == constant.Value;
}
else
{
if ((assignmentValue == null) || !assignmentValue.Equals(condRightSymbol))
return false;
}
return true;
}
// flipped operands
if (assignmentTarget.Equals(condRightSymbol))
{
if (constantAssignment)
{
var condLeftValue = nodeContext.SemanticModel.GetConstantValue(condition.Left);
if (condLeftValue.HasValue)
return condLeftValue.Value == constant.Value;
}
else
{
if ((assignmentValue == null) || !assignmentValue.Equals(condLeftSymbol))
return false;
}
return true;
}
return false;
}
开发者ID:yeaicc,项目名称:RefactoringEssentials,代码行数:52,代码来源:RedundantCheckBeforeAssignmentAnalyzer.cs
示例10: VisitAssignmentExpression
/// <summary>
/// Normalizes the <paramref name="assignment" />.
/// </summary>
public override SyntaxNode VisitAssignmentExpression(AssignmentExpressionSyntax assignment)
{
var objectCreation = assignment.Right as ObjectCreationExpressionSyntax;
if (objectCreation == null)
return assignment;
var fault = SemanticModel.GetTypeSymbol<Fault>();
if (SemanticModel.GetTypeInfo(objectCreation).Type?.IsDerivedFrom(fault) == false)
return assignment;
var targetSymbol = SemanticModel.GetSymbolInfo(assignment.Left).Symbol;
if (targetSymbol == null || (targetSymbol.Kind != SymbolKind.Field && targetSymbol.Kind != SymbolKind.Property))
return assignment;
return assignment.WithRight(AddNameInitializer(fault, objectCreation, targetSymbol.Name));
}
开发者ID:isse-augsburg,项目名称:ssharp,代码行数:19,代码来源:FaultNameNormalizer.cs
示例11: GetMemberAccessExpressionFromAssignment
private static MemberAccessExpressionSyntax GetMemberAccessExpressionFromAssignment(SemanticModel semanticModel, AssignmentExpressionSyntax assignmentExpression, AssignmentExpressionSyntax nullLiteralAssignment)
{
if (assignmentExpression == null || nullLiteralAssignment == null
|| !assignmentExpression.IsKind(SyntaxKind.SimpleAssignmentExpression)
|| !assignmentExpression.IsKind(SyntaxKind.SimpleAssignmentExpression))
return null;
if (!nullLiteralAssignment.Right.IsKind(SyntaxKind.NullLiteralExpression)) return null;
if (!nullLiteralAssignment.Left.IsKind(SyntaxKind.IdentifierName)) return null;
if (!assignmentExpression.Left.IsKind(SyntaxKind.IdentifierName)) return null;
var assignmentIdentifier = semanticModel.GetSymbolInfo(assignmentExpression.Left);
var nullLiteralAssignmentIdentifier = semanticModel.GetSymbolInfo(nullLiteralAssignment.Left);
if ((assignmentIdentifier.Symbol ?? nullLiteralAssignmentIdentifier.Symbol) == null) return null;
if (!assignmentIdentifier.Equals(nullLiteralAssignmentIdentifier)) return null;
var memberAccessExpression = assignmentExpression.Right as MemberAccessExpressionSyntax;
return memberAccessExpression;
}
开发者ID:JeanLLopes,项目名称:code-cracker,代码行数:16,代码来源:ExistenceOperatorAnalyzer.cs
示例12: AddVariableThatWasSkippedBeforeBecauseItLackedAInitializer
private static void AddVariableThatWasSkippedBeforeBecauseItLackedAInitializer(Dictionary<IFieldSymbol, VariableDeclaratorSyntax> variablesToMakeReadonly, IFieldSymbol fieldSymbol, AssignmentExpressionSyntax assignment)
{
var parent = assignment.Parent;
while (parent != null)
{
if (parent is AnonymousFunctionExpressionSyntax)
return;
if (parent is ConstructorDeclarationSyntax)
break;
parent = parent.Parent;
}
if (!fieldSymbol.IsReadOnly && !variablesToMakeReadonly.Keys.Contains(fieldSymbol))
foreach (var variable in fieldSymbol.DeclaringSyntaxReferences)
variablesToMakeReadonly.Add(fieldSymbol, (VariableDeclaratorSyntax)variable.GetSyntax());
}
开发者ID:Cadums01,项目名称:code-cracker,代码行数:16,代码来源:ReadonlyFieldAnalyzer.cs
示例13: VisitAssignmentExpression
/// <summary>
/// Normalizes the <paramref name="expression" /> if it represents a compound assignment.
/// </summary>
public override SyntaxNode VisitAssignmentExpression(AssignmentExpressionSyntax expression)
{
expression = (AssignmentExpressionSyntax)base.VisitAssignmentExpression(expression);
SyntaxKind expressionKind;
switch (expression.Kind())
{
case SyntaxKind.AddAssignmentExpression:
expressionKind = SyntaxKind.AddExpression;
break;
case SyntaxKind.SubtractAssignmentExpression:
expressionKind = SyntaxKind.SubtractExpression;
break;
case SyntaxKind.MultiplyAssignmentExpression:
expressionKind = SyntaxKind.MultiplyExpression;
break;
case SyntaxKind.DivideAssignmentExpression:
expressionKind = SyntaxKind.DivideExpression;
break;
case SyntaxKind.ModuloAssignmentExpression:
expressionKind = SyntaxKind.ModuloExpression;
break;
case SyntaxKind.AndAssignmentExpression:
expressionKind = SyntaxKind.LogicalAndExpression;
break;
case SyntaxKind.ExclusiveOrAssignmentExpression:
expressionKind = SyntaxKind.ExclusiveOrExpression;
break;
case SyntaxKind.OrAssignmentExpression:
expressionKind = SyntaxKind.LogicalOrExpression;
break;
case SyntaxKind.LeftShiftAssignmentExpression:
expressionKind = SyntaxKind.LeftShiftExpression;
break;
case SyntaxKind.RightShiftAssignmentExpression:
expressionKind = SyntaxKind.RightShiftExpression;
break;
default:
return expression;
}
var originalRightHand = (ExpressionSyntax)Visit(expression.Right);
var parenthesizedExpression = SyntaxFactory.ParenthesizedExpression(originalRightHand).WithLeadingSpace();
var rightHandExpression = SyntaxFactory.BinaryExpression(expressionKind, expression.Left.WithLeadingSpace(), parenthesizedExpression);
var simpleAssignment = SyntaxFactory.AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, expression.Left, rightHandExpression);
return simpleAssignment.WithTrivia(expression);
}
开发者ID:cubeme,项目名称:safety-sharp,代码行数:50,代码来源:CompoundAssignmentNormalizer.cs
示例14: CreateAssignment
internal static AssignmentExpressionSyntax CreateAssignment(AssignmentExpressionSyntax node)
{
var bop = node.Right as BinaryExpressionSyntax;
if (bop == null)
return null;
var outerLeft = GetOuterLeft(bop);
var outerLeftId = outerLeft as IdentifierNameSyntax;
var leftId = node.Left as IdentifierNameSyntax;
if (outerLeftId == null || leftId == null)
return null;
if (!outerLeftId.Identifier.Value.Equals (leftId.Identifier.Value))
return null;
var op = GetAssignmentOperator(bop.OperatorToken);
if (op == SyntaxKind.None)
return null;
return SyntaxFactory.AssignmentExpression(op, node.Left, SplitIfWithAndConditionInTwoCodeRefactoringProvider.GetRightSide(outerLeft.Parent as BinaryExpressionSyntax));
}
开发者ID:alecor191,项目名称:RefactoringEssentials,代码行数:17,代码来源:ReplaceWithOperatorAssignmentCodeRefactoringProvider.cs
示例15: VisitAssignmentExpression
/// <summary>
/// Normalizes the <paramref name="expression" />.
/// </summary>
public override SyntaxNode VisitAssignmentExpression(AssignmentExpressionSyntax expression)
{
if (!_inConstructor)
return expression;
var propertySymbol = SemanticModel.GetSymbolInfo(expression.Left).Symbol as IPropertySymbol;
expression = (AssignmentExpressionSyntax)base.VisitAssignmentExpression(expression);
if (propertySymbol == null || !propertySymbol.IsAutoProperty())
return expression;
if (propertySymbol.GetMethod != null && !propertySymbol.GetMethod.CanBeAffectedByFaults(SemanticModel))
return expression;
var fieldExpression = (ExpressionSyntax)Syntax.IdentifierName(GetBackingFieldName(propertySymbol)).WithTrivia(expression.Left);
return expression.WithLeft(fieldExpression);
}
开发者ID:isse-augsburg,项目名称:ssharp,代码行数:20,代码来源:AutoPropertyNormalizer.cs
示例16: BindDeconstruction
/// <summary>
/// Only handles assignment-only or declaration-only deconstructions at this point.
/// Issue https://github.com/dotnet/roslyn/issues/15050 tracks allowing mixed deconstructions
/// </summary>
private BoundExpression BindDeconstruction(AssignmentExpressionSyntax node, DiagnosticBag diagnostics)
{
var left = node.Left;
var right = node.Right;
if (node.IsDeconstructionDeclaration())
{
return BindDeconstructionDeclaration(node, left, right, diagnostics);
}
AssertDeconstructionIsAssignment(left);
var tuple = (TupleExpressionSyntax)left;
ArrayBuilder<DeconstructionVariable> checkedVariables = BindDeconstructionAssignmentVariables(tuple.Arguments, tuple, diagnostics);
var result = BindDeconstructionAssignment(node, node.Right, checkedVariables, diagnostics, isDeclaration: false);
FreeDeconstructionVariables(checkedVariables);
return result;
}
开发者ID:otawfik-ms,项目名称:roslyn,代码行数:22,代码来源:Binder_Deconstruct.cs
示例17: BindDeconstruction
private BoundExpression BindDeconstruction(AssignmentExpressionSyntax node, DiagnosticBag diagnostics)
{
var left = node.Left;
var right = node.Right;
DeclarationExpressionSyntax declaration = null;
ExpressionSyntax expression = null;
var result = BindDeconstruction(node, left, right, diagnostics, ref declaration, ref expression);
if (declaration != null)
{
// only allowed at the top level, or in a for loop
switch (node.Parent?.Kind())
{
case null:
case SyntaxKind.ExpressionStatement:
if (expression != null)
{
// We only allow assignment-only or declaration-only deconstructions at this point.
// Issue https://github.com/dotnet/roslyn/issues/15050 tracks allowing mixed deconstructions.
// For now we give an error when you mix.
Error(diagnostics, ErrorCode.ERR_MixedDeconstructionUnsupported, left);
}
break;
case SyntaxKind.ForStatement:
if (((ForStatementSyntax)node.Parent).Initializers.Contains(node))
{
if (expression != null)
{
Error(diagnostics, ErrorCode.ERR_MixedDeconstructionUnsupported, left);
}
}
else
{
Error(diagnostics, ErrorCode.ERR_DeclarationExpressionNotPermitted, declaration);
}
break;
default:
Error(diagnostics, ErrorCode.ERR_DeclarationExpressionNotPermitted, declaration);
break;
}
}
return result;
}
开发者ID:XieShuquan,项目名称:roslyn,代码行数:43,代码来源:Binder_Deconstruct.cs
示例18: AnalyzeAssignment
void AnalyzeAssignment(SyntaxNodeAnalysisContext context, AssignmentExpressionSyntax assignment)
{
var containingMethod = assignment.GetContainingMethod();
if (containingMethod.HasConstAttribute(context.SemanticModel)) {
if (context.SemanticModel.GetSymbolInfo(assignment.Left).Symbol?.Kind == SymbolKind.Local) {
return;
}
var left = assignment.Left as MemberAccessExpressionSyntax;
if (left != null) {
var walker = new Walker(context);
containingMethod.Accept(walker);
var exprSymbol = context.SemanticModel.GetSymbolInfo(left.Expression).Symbol;
if (exprSymbol != null && exprSymbol.Kind == SymbolKind.Local && !walker.UnsafeLocals.Contains(exprSymbol.Name)) {
return;
}
}
context.ReportDiagnostic(Diagnostic.Create(Rule, assignment.GetLocation(), context.SemanticModel.GetDeclaredSymbol(containingMethod)?.Name));
}
}
开发者ID:FonsDijkstra,项目名称:CConst,代码行数:20,代码来源:AssignmentInConstMethodAnalyzer.cs
示例19: CalculateNewRoot
private static SyntaxNode CalculateNewRoot(SyntaxNode root, Diagnostic diagnostic,
StatementSyntax currentAsStatement, AssignmentExpressionSyntax currentAsAssignment,
BinaryExpressionSyntax currentAsBinary)
{
if (currentAsStatement != null)
{
return root.RemoveNode(currentAsStatement, SyntaxRemoveOptions.KeepNoTrivia);
}
if (currentAsAssignment != null)
{
return root.ReplaceNode(
currentAsAssignment,
currentAsAssignment.Left.WithAdditionalAnnotations(Formatter.Annotation));
}
var isReportingOnLeft = bool.Parse(diagnostic.Properties[SillyBitwiseOperation.IsReportingOnLeftKey]);
return root.ReplaceNode(
currentAsBinary,
(isReportingOnLeft ? currentAsBinary.Right : currentAsBinary.Left).WithAdditionalAnnotations(Formatter.Annotation));
}
开发者ID:ozgurkayaist,项目名称:sonarlint-vs,代码行数:21,代码来源:SillyBitwiseOperationCodeFixProvider.cs
示例20: AnalyzeAssignment
void AnalyzeAssignment(SyntaxNodeAnalysisContext context, AssignmentExpressionSyntax assignment)
{
var constructor = assignment.GetContainingConstructor();
if (constructor == null)
{
return;
}
var symbol = context.SemanticModel.GetSymbolInfo(assignment.Left).Symbol;
if (symbol?.Kind == SymbolKind.Local)
{
return;
}
var constructorSymbol = context.SemanticModel.GetDeclaredSymbol(constructor);
if (symbol?.ContainingType == constructorSymbol.ContainingType)
{
return;
}
context.ReportDiagnostic(Diagnostic.Create(Rule, assignment.GetLocation(), constructorSymbol.Name));
}
开发者ID:FonsDijkstra,项目名称:CConst,代码行数:22,代码来源:ConstConstructorAnalyzer.cs
注:本文中的AssignmentExpressionSyntax类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论