本文整理汇总了C#中ObjectCreationExpressionSyntax类的典型用法代码示例。如果您正苦于以下问题:C# ObjectCreationExpressionSyntax类的具体用法?C# ObjectCreationExpressionSyntax怎么用?C# ObjectCreationExpressionSyntax使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ObjectCreationExpressionSyntax类属于命名空间,在下文中一共展示了ObjectCreationExpressionSyntax类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ChangeToImmutableArrayCreateRange
private static async Task<Document> ChangeToImmutableArrayCreateRange(
ObjectCreationExpressionSyntax objectCreation,
InitializerExpressionSyntax initializer,
INamedTypeSymbol immutableArrayType,
ITypeSymbol elementType,
Document document,
CancellationToken cancellationToken)
{
var generator = SyntaxGenerator.GetGenerator(document);
var arrayElementType = (TypeSyntax)generator.TypeExpression(elementType);
var arrayType = SyntaxFactory.ArrayType(arrayElementType,
SyntaxFactory.SingletonList(
SyntaxFactory.ArrayRankSpecifier(
SyntaxFactory.SingletonSeparatedList(
(ExpressionSyntax)SyntaxFactory.OmittedArraySizeExpression()))));
var arrayCreationExpression = SyntaxFactory.ArrayCreationExpression(
type: arrayType,
initializer: SyntaxFactory.InitializerExpression(
kind: SyntaxKind.ArrayInitializerExpression,
expressions: initializer.Expressions))
.WithAdditionalAnnotations(Formatter.Annotation);
var type = generator.TypeExpression(immutableArrayType);
var memberAccess = generator.MemberAccessExpression(type, "CreateRange");
var invocation = generator.InvocationExpression(memberAccess, arrayCreationExpression);
var oldRoot = await document.GetSyntaxRootAsync(cancellationToken);
var newRoot = oldRoot.ReplaceNode(objectCreation, invocation);
return document.WithSyntaxRoot(newRoot);
}
开发者ID:jwendl,项目名称:CoreFxAnalyzers,代码行数:33,代码来源:DoNotUseImmutableArrayCollectionInitializerCodeFix.cs
示例2: CheckExceptionType
internal static bool CheckExceptionType(SemanticModel model, ObjectCreationExpressionSyntax objectCreateExpression, out ExpressionSyntax paramNode)
{
paramNode = null;
var type = model.GetTypeInfo(objectCreateExpression).Type;
if (type == null)
return false;
if (type.Name == typeof(ArgumentException).Name)
{
if (objectCreateExpression.ArgumentList.Arguments.Count >= 2)
{
paramNode = objectCreateExpression.ArgumentList.Arguments[1].Expression;
}
return paramNode != null;
}
if (type.Name == typeof(ArgumentNullException).Name ||
type.Name == typeof(ArgumentOutOfRangeException).Name ||
type.Name == "DuplicateWaitObjectException")
{
if (objectCreateExpression.ArgumentList.Arguments.Count >= 1)
{
paramNode = objectCreateExpression.ArgumentList.Arguments[0].Expression;
}
return paramNode != null;
}
return false;
}
开发者ID:ceddlyburge,项目名称:RefactoringEssentials,代码行数:26,代码来源:NameOfSuggestionAnalyzer.cs
示例3: ObjectCreationExpression
public static string ObjectCreationExpression(ObjectCreationExpressionSyntax expression)
{
//Name all the arguments, since Swift usually requires named arguments when you create new objects.
//Thanks! http://stackoverflow.com/questions/24174602/get-constructor-declaration-from-objectcreationexpressionsyntax-with-roslyn/24191494#24191494
var symbol = Model.GetSymbolInfo(expression).Symbol as IMethodSymbol;
var namedArgumentsList = new SeparatedSyntaxList<ArgumentSyntax>();
for (var i = 0; i < expression.ArgumentList.Arguments.Count; i++)
{
var oldArgumentSyntax = expression.ArgumentList.Arguments[i];
var parameterName = symbol.Parameters[i].Name;
var nameColonSyntax = SyntaxFactory
.NameColon(SyntaxFactory.IdentifierName(parameterName))
.WithTrailingTrivia(SyntaxFactory.Whitespace(" "));
var namedArgumentSyntax = SyntaxFactory.Argument(nameColonSyntax, oldArgumentSyntax.RefOrOutKeyword, oldArgumentSyntax.Expression);
namedArgumentsList = namedArgumentsList.Add(namedArgumentSyntax);
}
//NOTE: this takes out expression.parent and everything, and probably screws with SyntaxModel stuff to
return SyntaxNode(expression.Type) + SyntaxNode(SyntaxFactory.ArgumentList(namedArgumentsList));
}
开发者ID:UIKit0,项目名称:SharpSwift,代码行数:25,代码来源:ExpressionSyntaxParser.cs
示例4: CreateUsing
public static SyntaxNode CreateUsing(SyntaxNode root, ObjectCreationExpressionSyntax objectCreation, SemanticModel semanticModel)
{
SyntaxNode newRoot;
if (objectCreation.Parent.IsKind(SyntaxKind.SimpleAssignmentExpression))
{
var assignmentExpression = (AssignmentExpressionSyntax)objectCreation.Parent;
var statement = assignmentExpression.Parent as ExpressionStatementSyntax;
var identitySymbol = (ILocalSymbol)semanticModel.GetSymbolInfo(assignmentExpression.Left).Symbol;
newRoot = UsedOutsideParentBlock(semanticModel, statement, identitySymbol)
? CreateRootAddingDisposeToEndOfMethod(root, statement, identitySymbol)
: CreateRootWithUsing(root, statement, u => u.WithExpression(assignmentExpression));
}
else if (objectCreation.Parent.IsKind(SyntaxKind.EqualsValueClause) && objectCreation.Parent.Parent.IsKind(SyntaxKind.VariableDeclarator))
{
var variableDeclarator = (VariableDeclaratorSyntax)objectCreation.Parent.Parent;
var variableDeclaration = (VariableDeclarationSyntax)variableDeclarator.Parent;
var statement = (LocalDeclarationStatementSyntax)variableDeclaration.Parent;
newRoot = CreateRootWithUsing(root, statement, u => u.WithDeclaration(variableDeclaration));
}
else
{
newRoot = CreateRootWithUsing(root, (ExpressionStatementSyntax)objectCreation.Parent, u => u.WithExpression(objectCreation));
}
return newRoot;
}
开发者ID:JeanLLopes,项目名称:code-cracker,代码行数:25,代码来源:DisposableVariableNotDisposedCodeFixProvider.cs
示例5: GetDelegateTypeConstructors
private IEnumerable<SignatureHelpItem> GetDelegateTypeConstructors(
ObjectCreationExpressionSyntax objectCreationExpression,
SemanticModel semanticModel,
ISymbolDisplayService symbolDisplayService,
IAnonymousTypeDisplayService anonymousTypeDisplayService,
INamedTypeSymbol delegateType,
INamedTypeSymbol containingType,
CancellationToken cancellationToken)
{
var invokeMethod = delegateType.DelegateInvokeMethod;
if (invokeMethod == null)
{
return null;
}
var position = objectCreationExpression.SpanStart;
var item = CreateItem(
invokeMethod, semanticModel, position,
symbolDisplayService, anonymousTypeDisplayService,
isVariadic: false,
documentationFactory: null,
prefixParts: GetDelegateTypePreambleParts(invokeMethod, semanticModel, position),
separatorParts: GetSeparatorParts(),
suffixParts: GetDelegateTypePostambleParts(invokeMethod),
parameters: GetDelegateTypeParameters(invokeMethod, semanticModel, position, cancellationToken));
return SpecializedCollections.SingletonEnumerable(item);
}
开发者ID:daking2014,项目名称:roslyn,代码行数:28,代码来源:ObjectCreationExpressionSignatureHelpProvider_DelegateType.cs
示例6: TryGetObjectCreationExpression
private bool TryGetObjectCreationExpression(SyntaxNode root, int position, ISyntaxFactsService syntaxFacts, SignatureHelpTriggerReason triggerReason, CancellationToken cancellationToken, out ObjectCreationExpressionSyntax expression)
{
if (!CommonSignatureHelpUtilities.TryGetSyntax(root, position, syntaxFacts, triggerReason, IsTriggerToken, IsArgumentListToken, cancellationToken, out expression))
{
return false;
}
return expression.ArgumentList != null;
}
开发者ID:jkotas,项目名称:roslyn,代码行数:9,代码来源:ObjectCreationExpressionSignatureHelpProvider.cs
示例7: GetClassificationForCommandCreation
public static bool GetClassificationForCommandCreation(ISemanticModel model, ObjectCreationExpressionSyntax syntax, CancellationToken cancellationToken = new CancellationToken())
{
if (syntax == null) return false;
var cmdType = model.GetSemanticInfo(syntax, cancellationToken);
//var cmdType = model.GetSemanticInfo(syntax, cancellationToken);
return cmdType.Type.AllInterfaces.AsList().Select(x => x.Name).Any(x => x == "ICommand");
}
开发者ID:jjrdk,项目名称:CqrsMessagingTools,代码行数:9,代码来源:MessageSendSyntaxClassifier.cs
示例8: CreateUsing
public static SyntaxNode CreateUsing(SyntaxNode root, ObjectCreationExpressionSyntax objectCreation, SemanticModel semanticModel)
{
SyntaxNode newRoot;
if (objectCreation.Parent.IsKind(SyntaxKind.SimpleAssignmentExpression))
{
var assignmentExpression = (AssignmentExpressionSyntax)objectCreation.Parent;
var statement = assignmentExpression.Parent as ExpressionStatementSyntax;
var identitySymbol = (ILocalSymbol)semanticModel.GetSymbolInfo(assignmentExpression.Left).Symbol;
newRoot = UsedOutsideParentBlock(semanticModel, statement, identitySymbol)
? CreateRootAddingDisposeToEndOfMethod(root, statement, identitySymbol)
: CreateRootWithUsing(root, statement, u => u.WithExpression(assignmentExpression));
}
else if (objectCreation.Parent.IsKind(SyntaxKind.EqualsValueClause) && objectCreation.Parent.Parent.IsKind(SyntaxKind.VariableDeclarator))
{
var variableDeclarator = (VariableDeclaratorSyntax)objectCreation.Parent.Parent;
var variableDeclaration = (VariableDeclarationSyntax)variableDeclarator.Parent;
var statement = (LocalDeclarationStatementSyntax)variableDeclaration.Parent;
newRoot = CreateRootWithUsing(root, statement, u => u.WithDeclaration(variableDeclaration.WithoutLeadingTrivia()));
}
else if (objectCreation.Parent.IsKind(SyntaxKind.Argument))
{
var identifierName = GetIdentifierName(objectCreation, semanticModel);
var variableDeclaration = SyntaxFactory.VariableDeclaration(SyntaxFactory.IdentifierName(@"var"))
.WithVariables(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.VariableDeclarator(SyntaxFactory.Identifier(identifierName))
.WithInitializer(SyntaxFactory.EqualsValueClause(SyntaxFactory.Token(SyntaxKind.EqualsToken), objectCreation))));
var arg = objectCreation.Parent as ArgumentSyntax;
var args = objectCreation.Parent.Parent as ArgumentListSyntax;
var newArgs = args.ReplaceNode(arg, arg.WithExpression(SyntaxFactory.IdentifierName(identifierName)));
StatementSyntax statement = objectCreation.FirstAncestorOfType<ExpressionStatementSyntax>();
if (statement != null)
{
var exprStatement = statement.ReplaceNode(args, newArgs);
var newUsingStatment = CreateUsingStatement(exprStatement, SyntaxFactory.Block(exprStatement))
.WithDeclaration(variableDeclaration);
return root.ReplaceNode(statement, newUsingStatment);
}
statement = (StatementSyntax)objectCreation.Ancestors().First(node => node is StatementSyntax);
var newStatement = statement.ReplaceNode(args, newArgs);
var statementsForUsing = new[] { newStatement }.Concat(GetChildStatementsAfter(statement));
var usingBlock = SyntaxFactory.Block(statementsForUsing);
var usingStatement = CreateUsingStatement(newStatement, usingBlock)
.WithDeclaration(variableDeclaration);
var statementsToReplace = new List<StatementSyntax> { statement };
statementsToReplace.AddRange(statementsForUsing.Skip(1));
newRoot = root.ReplaceNodes(statementsToReplace, (node, _) => node.Equals(statement) ? usingStatement : null);
}
else
{
newRoot = CreateRootWithUsing(root, (ExpressionStatementSyntax)objectCreation.Parent, u => u.WithExpression(objectCreation));
}
return newRoot;
}
开发者ID:Cadums01,项目名称:code-cracker,代码行数:56,代码来源:DisposableVariableNotDisposedCodeFixProvider.cs
示例9: BoundObjectCreationExpression
public BoundObjectCreationExpression(
IType type,
IConstructor boundConstructor,
List<BoundExpression> boundParameter,
ObjectCreationExpressionSyntax expressionSyntax)
: base(expressionSyntax, type)
{
BoundConstructor = boundConstructor;
BoundParameter = boundParameter;
}
开发者ID:lawl-dev,项目名称:Kiwi,代码行数:10,代码来源:BoundObjectCreationExpression.cs
示例10: ChangeToImmutableArrayEmpty
private static async Task<Document> ChangeToImmutableArrayEmpty(ObjectCreationExpressionSyntax objectCreation, Document document, CancellationToken cancellationToken)
{
var generator = SyntaxGenerator.GetGenerator(document);
var memberAccess = generator.MemberAccessExpression(objectCreation.Type, "Empty");
var oldRoot = await document.GetSyntaxRootAsync(cancellationToken);
var newRoot = oldRoot.ReplaceNode(objectCreation, memberAccess);
return document.WithSyntaxRoot(newRoot);
}
开发者ID:jwendl,项目名称:CoreFxAnalyzers,代码行数:10,代码来源:DoNotUseImmutableArrayCtorCodeFix.cs
示例11: VisitObjectCreationExpression
public override void VisitObjectCreationExpression(ObjectCreationExpressionSyntax node)
{
var symbol = (IMethodSymbol)SemanticModel.GetSymbolInfo(node).Symbol;
if (symbol != null)
{
IsAsyncLibraryConstruct(symbol.OriginalDefinition);
}
base.VisitObjectCreationExpression(node);
}
开发者ID:modulexcite,项目名称:concurrent-code-analyses,代码行数:11,代码来源:AsyncLibraryDetectionWalker.cs
示例12: CreateNewBlockParent
private static BlockSyntax CreateNewBlockParent(StatementSyntax statement, SemanticModel semanticModel, ObjectCreationExpressionSyntax objectCreationExpression, ISymbol variableSymbol)
{
var blockParent = statement.FirstAncestorOrSelf<BlockSyntax>();
var assignmentExpressions = ObjectInitializerAnalyzer.FindAssignmentExpressions(semanticModel, statement, variableSymbol);
var newBlockParent = SyntaxFactory.Block()
.WithLeadingTrivia(blockParent.GetLeadingTrivia())
.WithTrailingTrivia(blockParent.GetTrailingTrivia())
.WithAdditionalAnnotations(Formatter.Annotation);
var newAssignmentExpressions = new List<ExpressionStatementSyntax>();
for (int i = 0; i < blockParent.Statements.Count; i++)
{
var blockStatement = blockParent.Statements[i];
if (blockStatement.Equals(statement))
{
var initializationExpressions = new List<AssignmentExpressionSyntax>();
foreach (var expressionStatement in assignmentExpressions)
{
var assignmentExpression = expressionStatement.Expression as AssignmentExpressionSyntax;
var memberAccess = assignmentExpression.Left as MemberAccessExpressionSyntax;
var propertyIdentifier = memberAccess.Name as IdentifierNameSyntax;
initializationExpressions.Add(SyntaxFactory.AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, propertyIdentifier, assignmentExpression.Right));
}
var initializers = SyntaxFactory.SeparatedList<ExpressionSyntax>(initializationExpressions);
var newObjectCreationExpression = objectCreationExpression.WithInitializer(
SyntaxFactory.InitializerExpression(
SyntaxKind.ObjectInitializerExpression,
SyntaxFactory.Token(SyntaxFactory.ParseLeadingTrivia(" "), SyntaxKind.OpenBraceToken, SyntaxFactory.ParseTrailingTrivia("\n")),
initializers,
SyntaxFactory.Token(SyntaxFactory.ParseLeadingTrivia(" "), SyntaxKind.CloseBraceToken, SyntaxFactory.ParseTrailingTrivia(""))
))
.WithLeadingTrivia(objectCreationExpression.GetLeadingTrivia())
.WithTrailingTrivia(objectCreationExpression.GetTrailingTrivia())
.WithAdditionalAnnotations(Formatter.Annotation);
if (newObjectCreationExpression.ArgumentList?.Arguments.Count == 0)
{
newObjectCreationExpression = newObjectCreationExpression.WithArgumentList(null);
}
var newLocalDeclarationStatement = statement.ReplaceNode(objectCreationExpression, newObjectCreationExpression)
.WithLeadingTrivia(statement.GetLeadingTrivia())
.WithTrailingTrivia(statement.GetTrailingTrivia())
.WithAdditionalAnnotations(Formatter.Annotation);
newBlockParent = newBlockParent.AddStatements(newLocalDeclarationStatement);
i += initializationExpressions.Count;
}
else
{
newBlockParent = newBlockParent.AddStatements(blockStatement
.WithLeadingTrivia(blockStatement.GetLeadingTrivia())
.WithTrailingTrivia(blockStatement.GetTrailingTrivia())
.WithAdditionalAnnotations(Formatter.Annotation));
}
}
return newBlockParent;
}
开发者ID:freneza,项目名称:code-cracker,代码行数:54,代码来源:ObjectInitializerCodeFixProvider.cs
示例13: VisitObjectCreationExpression
public override void VisitObjectCreationExpression(ObjectCreationExpressionSyntax node)
{
var symbol = SemanticModel.GetSymbolInfo(node).Symbol;
if (symbol != null)
{
Enums.ThreadingNamespaceDetected type = CheckThreadingUsage(symbol);
Result.StoreDetectedThreadingNamespaceUsage(type);
Result.WriteDetectedThreadingNamespaceUsage(type, Document.FilePath, symbol, node);
}
base.VisitObjectCreationExpression(node);
}
开发者ID:modulexcite,项目名称:concurrent-code-analyses,代码行数:12,代码来源:ThreadUsageDetectionWalker.cs
示例14: IsDefaultCtorOnStruct
private bool IsDefaultCtorOnStruct(ObjectCreationExpressionSyntax objectCreation, ITypeSymbol symbol, SemanticModel semanticModel)
{
if (symbol.IsValueType)
{
var ctor = semanticModel.GetSymbolInfo(objectCreation).Symbol as IMethodSymbol;
if (ctor != null)
{
return ctor.Parameters.Length == 0;
}
}
return false;
}
开发者ID:SergeyTeplyakov,项目名称:ErrorProne.NET,代码行数:13,代码来源:AssignmentFreePureObjectConstructionAnalyzer.cs
示例15: GetValidParameterNames
internal static List<string> GetValidParameterNames(ObjectCreationExpressionSyntax objectCreateExpression)
{
var names = new List<string>();
var node = objectCreateExpression.Parent;
while (node != null && !(node is TypeBlockSyntax) && !(node is AnonymousObjectCreationExpressionSyntax))
{
var lambda = node as LambdaExpressionSyntax;
if (lambda != null)
{
names.AddRange(lambda.SubOrFunctionHeader.ParameterList.Parameters.Select(p => p.Identifier.ToString()));
break;
}
var indexer = node as PropertyBlockSyntax;
if ((indexer != null) && (indexer.PropertyStatement.ParameterList != null))
{
names.AddRange(indexer.PropertyStatement.ParameterList.Parameters.Select(p => p.Identifier.ToString()));
break;
}
var methodDeclaration = node as MethodBlockSyntax;
if (methodDeclaration != null)
{
names.AddRange(methodDeclaration.SubOrFunctionStatement.ParameterList.Parameters.Select(p => p.Identifier.ToString()));
break;
}
var constructorDeclaration = node as ConstructorBlockSyntax;
if (constructorDeclaration != null)
{
names.AddRange(constructorDeclaration.SubNewStatement.ParameterList.Parameters.Select(p => p.Identifier.ToString()));
break;
}
var accessor = node as AccessorBlockSyntax;
if (accessor != null)
{
if (accessor.IsKind(SyntaxKind.SetAccessorBlock) ||
accessor.IsKind(SyntaxKind.AddHandlerAccessorBlock) ||
accessor.IsKind(SyntaxKind.RemoveHandlerAccessorBlock))
{
names.Add("value");
}
var propertyParent = node.Parent as PropertyBlockSyntax;
if ((propertyParent == null) || (propertyParent.PropertyStatement.ParameterList == null))
break;
}
node = node.Parent;
}
return names;
}
开发者ID:alecor191,项目名称:RefactoringEssentials,代码行数:51,代码来源:NameOfSuggestionAnalyzer.cs
示例16: VisitObjectCreationExpression
public override SyntaxNode VisitObjectCreationExpression(ObjectCreationExpressionSyntax node)
{
node = (ObjectCreationExpressionSyntax)base.VisitObjectCreationExpression(node);
// new QueryParameter ("nr", DataType.String, referenceVersion.PatchNumber)
var identifier = node.Type as IdentifierNameSyntax;
if (identifier != null && identifier.HasTrailingTrivia)
{
this.addedAnnotations = true;
return node.ReplaceNode(identifier, identifier.WithoutTrailingTrivia());
}
return node;
}
开发者ID:OliverKurowski,项目名称:StylecopCodeFormatter,代码行数:15,代码来源:SA1008_NoWhitespaceBeforeParenthesis.cs
示例17: ChangeToGenericAsync
private async Task<Document> ChangeToGenericAsync(CodeFixContext context, SyntaxNode root, ObjectCreationExpressionSyntax creation)
{
// Compute new uppercase name.
var typeofSyntax = (TypeOfExpressionSyntax) creation.ArgumentList.Arguments[0].Expression;
var type = typeofSyntax.Type;
var originalEngine = creation.Type;
var newRoot = root.ReplaceNode(creation,
SyntaxFactory.ObjectCreationExpression(SyntaxFactory.Token(SyntaxKind.NewKeyword),
SyntaxFactory.ParseTypeName(originalEngine + "<" + type + ">"), SyntaxFactory.ArgumentList(), null));
return context.Document.WithSyntaxRoot(newRoot);
}
开发者ID:luksio,项目名称:FileHelpers,代码行数:15,代码来源:UseGenericEngineCodeFixProvider.cs
示例18: VisitObjectCreationExpression
public override SyntaxNode VisitObjectCreationExpression(ObjectCreationExpressionSyntax node)
{
if (IsChangeInObjectCreation)
{
return base.VisitObjectCreationExpression(node);
}
var found = FindListNode(node);
if(found == null)
{
return base.VisitObjectCreationExpression(node);
}
ListToArrayReplacementRewriter rewriter = new ListToArrayReplacementRewriter(true);
return rewriter.Visit(node);
}
开发者ID:nhabuiduc,项目名称:TypescriptSyntaxPaste,代码行数:16,代码来源:ListToArrayReplacement.cs
示例19: GetNormalTypeConstructors
private IList<SignatureHelpItem> GetNormalTypeConstructors(
Document document,
ObjectCreationExpressionSyntax objectCreationExpression,
SemanticModel semanticModel,
ISymbolDisplayService symbolDisplayService,
IAnonymousTypeDisplayService anonymousTypeDisplayService,
IDocumentationCommentFormattingService documentationCommentFormattingService,
INamedTypeSymbol normalType,
ISymbol within,
CancellationToken cancellationToken)
{
var accessibleConstructors = normalType.InstanceConstructors
.Where(c => c.IsAccessibleWithin(within))
.Where(s => s.IsEditorBrowsable(document.ShouldHideAdvancedMembers(), semanticModel.Compilation))
.Sort(symbolDisplayService, semanticModel, objectCreationExpression.SpanStart);
return accessibleConstructors.Select(c =>
ConvertNormalTypeConstructor(c, objectCreationExpression, semanticModel, symbolDisplayService, anonymousTypeDisplayService, documentationCommentFormattingService, cancellationToken)).ToList();
}
开发者ID:Rickinio,项目名称:roslyn,代码行数:19,代码来源:ObjectCreationExpressionSignatureHelpProvider_NormalType.cs
示例20: GetInvalidArgument
private static SyntaxToken? GetInvalidArgument(
ObjectCreationExpressionSyntax creationToken, SemanticModel model)
{
foreach (var argument in creationToken.ArgumentList.Arguments)
{
var argumentExpression = argument.Expression as MemberAccessExpressionSyntax;
if (argumentExpression != null)
{
var argumentSymbolNode = model.GetSymbolInfo(argumentExpression).Symbol;
if (argumentSymbolNode.ContainingType.ToDisplayString() ==
Values.ExpectedContainingDateTimeKindTypeDisplayString)
{
return argumentExpression.Name.Identifier;
}
}
}
return null;
}
开发者ID:JasonBock,项目名称:FindingDateTimeNow,代码行数:20,代码来源:FindingNewDateTimeAnalyzer.cs
注:本文中的ObjectCreationExpressionSyntax类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论