本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.Syntax.EqualsValueClauseSyntax类的典型用法代码示例。如果您正苦于以下问题:C# EqualsValueClauseSyntax类的具体用法?C# EqualsValueClauseSyntax怎么用?C# EqualsValueClauseSyntax使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EqualsValueClauseSyntax类属于Microsoft.CodeAnalysis.CSharp.Syntax命名空间,在下文中一共展示了EqualsValueClauseSyntax类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Declaration
public static LocalDeclarationStatementSyntax Declaration(string type, string variableName, EqualsValueClauseSyntax equalsValue)
{
return SyntaxFactory.LocalDeclarationStatement(
SyntaxFactory.VariableDeclaration(Identifier.Name(type))
.WithVariables(Declarator(variableName, equalsValue).AsList()))
.WithSemicolonToken(Token.SemiColon);
}
开发者ID:FociSolutions,项目名称:Foci.CodeGeneration,代码行数:8,代码来源:Variable.cs
示例2: PrivateDeclation
public static FieldDeclarationSyntax PrivateDeclation(string type, string variableName, EqualsValueClauseSyntax equalsValue)
{
return SyntaxFactory.FieldDeclaration(Declaration(SyntaxFactory.ParseTypeName(type),
SyntaxFactory.VariableDeclarator(
Identifier.Token(variableName),
null,
equalsValue)))
.WithModifiers(Token.Private.AsList());
}
开发者ID:FociSolutions,项目名称:Foci.CodeGeneration,代码行数:9,代码来源:Variable.cs
示例3: MakeLocal
public static SourceLocalSymbol MakeLocal(
MethodSymbol containingMethod,
Binder binder,
TypeSyntax typeSyntax,
SyntaxToken identifierToken,
EqualsValueClauseSyntax initializer,
LocalDeclarationKind declarationKind)
{
Debug.Assert(declarationKind != LocalDeclarationKind.ForEach);
return new SourceLocalSymbol(containingMethod, binder, typeSyntax, identifierToken, initializer, null, declarationKind);
}
开发者ID:riversky,项目名称:roslyn,代码行数:11,代码来源:SourceLocalSymbol.cs
示例4: MakeLocalWithInitializer
public static SourceLocalSymbol MakeLocalWithInitializer(
Symbol containingSymbol,
Binder binder,
TypeSyntax typeSyntax,
SyntaxToken identifierToken,
EqualsValueClauseSyntax initializer,
LocalDeclarationKind declarationKind)
{
Debug.Assert(declarationKind != LocalDeclarationKind.ForEachIterationVariable);
return new LocalWithInitializer(containingSymbol, binder, typeSyntax, identifierToken, initializer, declarationKind);
}
开发者ID:EkardNT,项目名称:Roslyn,代码行数:11,代码来源:SourceLocalSymbol.cs
示例5: PropertyDeclaration
public static PropertyDeclarationSyntax PropertyDeclaration(SyntaxList<AttributeListSyntax> attributeLists, SyntaxTokenList modifiers, TypeSyntax type, ExplicitInterfaceSpecifierSyntax explicitInterfaceSpecifier, SyntaxToken identifier, AccessorListSyntax accessorList, ArrowExpressionClauseSyntax expressionBody, EqualsValueClauseSyntax initializer, SyntaxToken semicolonToken)
{
return PropertyDeclaration(
attributeLists,
modifiers,
refKeyword: default(SyntaxToken),
type: type,
explicitInterfaceSpecifier: explicitInterfaceSpecifier,
identifier: identifier,
accessorList: accessorList,
expressionBody: expressionBody,
initializer: initializer,
semicolonToken: semicolonToken);
}
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:14,代码来源:PropertyDeclarationSyntax.cs
示例6: BindFieldOrEnumInitializer
private static BoundExpression BindFieldOrEnumInitializer(
Binder binder,
FieldSymbol fieldSymbol,
EqualsValueClauseSyntax initializer,
DiagnosticBag diagnostics)
{
var enumConstant = fieldSymbol as SourceEnumConstantSymbol;
var collisionDetector = new LocalScopeBinder(binder);
if ((object)enumConstant != null)
{
return collisionDetector.BindEnumConstantInitializer(enumConstant, initializer.Value, diagnostics);
}
else
{
return collisionDetector.BindVariableOrAutoPropInitializer(initializer, fieldSymbol.Type, diagnostics);
}
}
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:17,代码来源:ConstantValueUtils.cs
示例7: EvaluateFieldConstant
public static ConstantValue EvaluateFieldConstant(
SourceFieldSymbol symbol,
EqualsValueClauseSyntax equalsValueNode,
HashSet<SourceFieldSymbolWithSyntaxReference> dependencies,
bool earlyDecodingWellKnownAttributes,
DiagnosticBag diagnostics)
{
var compilation = symbol.DeclaringCompilation;
var binderFactory = compilation.GetBinderFactory((SyntaxTree)symbol.Locations[0].SourceTree);
var binder = binderFactory.GetBinder(equalsValueNode);
if (earlyDecodingWellKnownAttributes)
{
binder = new EarlyWellKnownAttributeBinder(binder);
}
var inProgressBinder = new ConstantFieldsInProgressBinder(new ConstantFieldsInProgress(symbol, dependencies), binder);
var boundValue = BindFieldOrEnumInitializer(inProgressBinder, symbol, equalsValueNode, diagnostics);
var initValueNodeLocation = equalsValueNode.Value.Location;
var value = GetAndValidateConstantValue(boundValue, symbol, symbol.Type, initValueNodeLocation, diagnostics);
Debug.Assert(value != null);
return value;
}
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:23,代码来源:ConstantValueUtils.cs
示例8: SourceLocalSymbol
private SourceLocalSymbol(
MethodSymbol containingMethod,
Binder binder,
TypeSyntax typeSyntax,
SyntaxToken identifierToken,
EqualsValueClauseSyntax initializer,
ExpressionSyntax collection,
LocalDeclarationKind declarationKind)
{
Debug.Assert(identifierToken.CSharpKind() != SyntaxKind.None);
Debug.Assert(declarationKind != LocalDeclarationKind.CompilerGenerated);
this.binder = binder;
this.containingMethod = containingMethod;
this.identifierToken = identifierToken;
this.typeSyntax = typeSyntax;
this.initializer = initializer;
this.collection = collection;
this.declarationKind = declarationKind;
// create this eagerly as it will always be needed for the EnsureSingleDefinition
this.locations = ImmutableArray.Create<Location>(identifierToken.GetLocation());
}
开发者ID:riversky,项目名称:roslyn,代码行数:23,代码来源:SourceLocalSymbol.cs
示例9: MakeLocal
public static SourceLocalSymbol MakeLocal(
Symbol containingSymbol,
Binder binder,
RefKind refKind,
TypeSyntax typeSyntax,
SyntaxToken identifierToken,
LocalDeclarationKind declarationKind,
EqualsValueClauseSyntax initializer = null)
{
Debug.Assert(declarationKind != LocalDeclarationKind.ForEachIterationVariable);
if (initializer == null)
{
DeclarationExpressionSyntax declarationExpression;
if (identifierToken.IsIdentifierOfOutVariableDeclaration(out declarationExpression))
{
if (declarationExpression.Type().IsVar)
{
return new PossiblyImplicitlyTypedOutVarLocalSymbol(containingSymbol, binder, refKind, typeSyntax, identifierToken, declarationKind);
}
}
return new SourceLocalSymbol(containingSymbol, binder, refKind, typeSyntax, identifierToken, declarationKind);
}
return new LocalWithInitializer(containingSymbol, binder, refKind, typeSyntax, identifierToken, initializer, declarationKind);
}
开发者ID:Shiney,项目名称:roslyn,代码行数:26,代码来源:SourceLocalSymbol.cs
示例10: BindFieldInitializer
private static BoundFieldInitializer BindFieldInitializer(Binder binder, FieldSymbol fieldSymbol, EqualsValueClauseSyntax equalsValueClauseNode,
DiagnosticBag diagnostics)
{
Debug.Assert(!fieldSymbol.IsMetadataConstant);
var fieldsBeingBound = binder.FieldsBeingBound;
var sourceField = fieldSymbol as SourceMemberFieldSymbol;
bool isImplicitlyTypedField = (object)sourceField != null && sourceField.FieldTypeInferred(fieldsBeingBound);
// If the type is implicitly typed, the initializer diagnostics have already been reported, so ignore them here:
// CONSIDER (tomat): reusing the bound field initializers for implicitly typed fields.
DiagnosticBag initializerDiagnostics;
if (isImplicitlyTypedField)
{
initializerDiagnostics = DiagnosticBag.GetInstance();
}
else
{
initializerDiagnostics = diagnostics;
}
var collisionDetector = new LocalScopeBinder(binder);
var boundInitValue = collisionDetector.BindVariableOrAutoPropInitializer(equalsValueClauseNode, fieldSymbol.GetFieldType(fieldsBeingBound), initializerDiagnostics);
if (isImplicitlyTypedField)
{
initializerDiagnostics.Free();
}
return new BoundFieldInitializer(
equalsValueClauseNode.Value, //we want the attached sequence point to indicate the value node
fieldSymbol,
boundInitValue);
}
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:35,代码来源:Compiler.cs
示例11: BindInferredVariableInitializer
// The location where the error is reported might not be the initializer.
internal BoundExpression BindInferredVariableInitializer(DiagnosticBag diagnostics, EqualsValueClauseSyntax initializer,
CSharpSyntaxNode errorSyntax)
{
if (initializer == null)
{
if (!errorSyntax.HasErrors)
{
Error(diagnostics, ErrorCode.ERR_ImplicitlyTypedVariableWithNoInitializer, errorSyntax);
}
return null;
}
if (initializer.Value.Kind() == SyntaxKind.ArrayInitializerExpression)
{
return BindUnexpectedArrayInitializer((InitializerExpressionSyntax)initializer.Value,
diagnostics, ErrorCode.ERR_ImplicitlyTypedVariableAssignedArrayInitializer, errorSyntax);
}
BoundExpression expression = BindValue(initializer.Value, diagnostics, BindValueKind.RValue);
// Certain expressions (null literals, method groups and anonymous functions) have no type of
// their own and therefore cannot be the initializer of an implicitly typed local.
if (!expression.HasAnyErrors && !expression.HasExpressionType())
{
MessageID id = MessageID.IDS_NULL;
if (expression.Kind == BoundKind.UnboundLambda)
{
id = ((UnboundLambda)expression).MessageID;
}
else if (expression.Kind == BoundKind.MethodGroup)
{
id = MessageID.IDS_MethodGroup;
}
else
{
Debug.Assert(expression.IsLiteralNull(), "How did we successfully bind an expression without a type?");
}
// Cannot assign {0} to an implicitly-typed local variable
Error(diagnostics, ErrorCode.ERR_ImplicitlyTypedVariableAssignedBadValue, errorSyntax, id.Localize());
}
return expression;
}
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:46,代码来源:Binder_Statements.cs
示例12: LocateDeclaredVariableSymbol
private SourceLocalSymbol LocateDeclaredVariableSymbol(SyntaxToken identifier, TypeSyntax typeSyntax, EqualsValueClauseSyntax equalsValue)
{
SourceLocalSymbol localSymbol = this.LookupLocal(identifier);
// In error scenarios with misplaced code, it is possible we can't bind the local declaration.
// This occurs through the semantic model. In that case concoct a plausible result.
if ((object)localSymbol == null)
{
localSymbol = SourceLocalSymbol.MakeLocal(
ContainingMemberOrLambda,
this,
false, // do not allow ref
typeSyntax,
identifier,
LocalDeclarationKind.RegularVariable,
equalsValue);
}
return localSymbol;
}
开发者ID:abock,项目名称:roslyn,代码行数:20,代码来源:Binder_Statements.cs
示例13: EqualsValueClauseNotSuitableForVar
private static bool EqualsValueClauseNotSuitableForVar(
SyntaxToken identifier,
TypeSyntax simpleName,
EqualsValueClauseSyntax equalsValueClause,
SemanticModel semanticModel,
CancellationToken cancellationToken)
{
// var cannot be assigned null
if (equalsValueClause.IsKind(SyntaxKind.NullLiteralExpression))
{
return true;
}
var type = semanticModel.GetTypeInfo(simpleName, cancellationToken).Type;
// the variable cannot be initialized to a method group or an anonymous function
if (type != null &&
type.TypeKind == TypeKind.Delegate)
{
return true;
}
var initializerType = semanticModel.GetTypeInfo(equalsValueClause.Value, cancellationToken).Type;
if (!type.Equals(initializerType))
{
return true;
}
// The assign expression in the initializer cannot be the same symbol as the i
var possibleSameLocals = equalsValueClause.DescendantNodesAndSelf().Where(n => n.Kind() == SyntaxKind.IdentifierName && ((IdentifierNameSyntax)n).Identifier.ValueText.Equals(identifier.ValueText));
var anyUse = possibleSameLocals.Any(n =>
{
var symbol = semanticModel.GetSymbolInfo(n, cancellationToken).Symbol;
if (symbol != null && symbol.Kind == SymbolKind.Local)
{
return true;
}
return false;
});
if (anyUse)
{
return true;
}
return false;
}
开发者ID:nileshjagtap,项目名称:roslyn,代码行数:49,代码来源:ExpressionSyntaxExtensions.cs
示例14: BindInferredVariableInitializer
// The location where the error is reported might not be the initializer.
protected BoundExpression BindInferredVariableInitializer(DiagnosticBag diagnostics, EqualsValueClauseSyntax initializer, BindValueKind valueKind,
CSharpSyntaxNode errorSyntax)
{
if (initializer == null)
{
if (!errorSyntax.HasErrors)
{
Error(diagnostics, ErrorCode.ERR_ImplicitlyTypedVariableWithNoInitializer, errorSyntax);
}
return null;
}
if (initializer.Value.Kind() == SyntaxKind.ArrayInitializerExpression)
{
return BindUnexpectedArrayInitializer((InitializerExpressionSyntax)initializer.Value,
diagnostics, ErrorCode.ERR_ImplicitlyTypedVariableAssignedArrayInitializer, errorSyntax);
}
BoundExpression expression = BindValue(initializer.Value, diagnostics, valueKind);
// Certain expressions (null literals, method groups and anonymous functions) have no type of
// their own and therefore cannot be the initializer of an implicitly typed local.
if (!expression.HasAnyErrors && !expression.HasExpressionType())
{
// Cannot assign {0} to an implicitly-typed local variable
Error(diagnostics, ErrorCode.ERR_ImplicitlyTypedVariableAssignedBadValue, errorSyntax, expression.Display);
}
return expression;
}
开发者ID:Shiney,项目名称:roslyn,代码行数:32,代码来源:Binder_Statements.cs
示例15: LocalWithInitializer
public LocalWithInitializer(
Symbol containingSymbol,
Binder binder,
RefKind refKind,
TypeSyntax typeSyntax,
SyntaxToken identifierToken,
EqualsValueClauseSyntax initializer,
LocalDeclarationKind declarationKind) :
base(containingSymbol, binder, refKind, typeSyntax, identifierToken, declarationKind)
{
Debug.Assert(declarationKind != LocalDeclarationKind.ForEachIterationVariable);
Debug.Assert(initializer != null);
_initializer = initializer;
// byval locals are always returnable
// byref locals with initializers are assumed not returnable unless proven otherwise
// NOTE: if we assumed returnable, then self-referring initializer could result in
// a randomly changing returnability when initializer is bound concurrently.
_returnable = refKind == RefKind.None;
}
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:21,代码来源:SourceLocalSymbol.cs
示例16: VisitEqualsValueClause
public override void VisitEqualsValueClause(EqualsValueClauseSyntax node)
{
var valueBinder = new ExpressionVariableBinder(node, _enclosing);
AddToMap(node, valueBinder);
Visit(node.Value, valueBinder);
}
开发者ID:XieShuquan,项目名称:roslyn,代码行数:6,代码来源:LocalBinderFactory.cs
示例17: FieldInitializerInfo
public FieldInitializerInfo(FieldInitializer initializer, Binder binder, EqualsValueClauseSyntax equalsValue)
{
Initializer = initializer;
Binder = binder;
EqualsValue = equalsValue;
}
开发者ID:EkardNT,项目名称:Roslyn,代码行数:6,代码来源:FieldInitializer.cs
示例18: VisitEqualsValueClause
public override SyntaxNode VisitEqualsValueClause(EqualsValueClauseSyntax node)
{
this.VisitExpression(node.Value);
return node;
}
开发者ID:rexzh,项目名称:SharpJs,代码行数:5,代码来源:Rewriter_BasicStructure.cs
示例19: InferTypeInEqualsValueClause
private IEnumerable<ITypeSymbol> InferTypeInEqualsValueClause(EqualsValueClauseSyntax equalsValue, SyntaxToken? previousToken = null)
{
// If we have a position, it has to be after the =
if (previousToken.HasValue && previousToken.Value != equalsValue.EqualsToken)
{
return SpecializedCollections.EmptyEnumerable<ITypeSymbol>();
}
if (equalsValue.IsParentKind(SyntaxKind.VariableDeclarator))
{
return InferTypeInVariableDeclarator((VariableDeclaratorSyntax)equalsValue.Parent);
}
if (equalsValue.IsParentKind(SyntaxKind.Parameter))
{
var parameter = this.semanticModel.GetDeclaredSymbol(equalsValue.Parent, cancellationToken) as IParameterSymbol;
if (parameter != null)
{
return SpecializedCollections.SingletonEnumerable(parameter.Type);
}
}
return SpecializedCollections.EmptyEnumerable<ITypeSymbol>();
}
开发者ID:jerriclynsjohn,项目名称:roslyn,代码行数:24,代码来源:CSharpTypeInferenceService.TypeInferrer.cs
示例20: MakeLocal
/// <summary>
/// Make a local variable symbol which can be inferred (if necessary) by binding its initializing expression.
/// </summary>
/// <param name="containingSymbol"></param>
/// <param name="scopeBinder">
/// Binder that owns the scope for the local, the one that returns it in its <see cref="Binder.Locals"/> array.
/// </param>
/// <param name="allowRefKind"></param>
/// <param name="typeSyntax"></param>
/// <param name="identifierToken"></param>
/// <param name="declarationKind"></param>
/// <param name="initializer"></param>
/// <param name="initializerBinderOpt">
/// Binder that should be used to bind initializer, if different from the <paramref name="scopeBinder"/>.
/// </param>
/// <returns></returns>
public static SourceLocalSymbol MakeLocal(
Symbol containingSymbol,
Binder scopeBinder,
bool allowRefKind,
TypeSyntax typeSyntax,
SyntaxToken identifierToken,
LocalDeclarationKind declarationKind,
EqualsValueClauseSyntax initializer = null,
Binder initializerBinderOpt = null)
{
Debug.Assert(declarationKind != LocalDeclarationKind.ForEachIterationVariable);
return (initializer != null)
? new LocalWithInitializer(containingSymbol, scopeBinder, typeSyntax, identifierToken, initializer, initializerBinderOpt ?? scopeBinder, declarationKind)
: new SourceLocalSymbol(containingSymbol, scopeBinder, allowRefKind, typeSyntax, identifierToken, declarationKind);
}
开发者ID:GuilhermeSa,项目名称:roslyn,代码行数:31,代码来源:SourceLocalSymbol.cs
注:本文中的Microsoft.CodeAnalysis.CSharp.Syntax.EqualsValueClauseSyntax类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论