本文整理汇总了C#中TypeParameterDeclaration类的典型用法代码示例。如果您正苦于以下问题:C# TypeParameterDeclaration类的具体用法?C# TypeParameterDeclaration怎么用?C# TypeParameterDeclaration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TypeParameterDeclaration类属于命名空间,在下文中一共展示了TypeParameterDeclaration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitTypeParameterDeclaration
public override void VisitTypeParameterDeclaration (TypeParameterDeclaration decl)
{
base.VisitTypeParameterDeclaration (decl);
var resolveResult = ctx.Resolve (decl) as TypeResolveResult;
if (resolveResult == null)
return;
var typeParameter = resolveResult.Type as ITypeParameter;
if (typeParameter == null)
return;
var methodDecl = decl.Parent as MethodDeclaration;
if (methodDecl == null)
return;
if (FindUsage (ctx, unit, typeParameter, decl))
return;
AddIssue (decl.NameToken, ctx.TranslateString ("Type parameter is never used"));
}
示例2: VisitTypeParameterDeclaration
public void VisitTypeParameterDeclaration(TypeParameterDeclaration typeParameterDeclaration)
{
StartNode(typeParameterDeclaration);
WriteAttributes(typeParameterDeclaration.Attributes);
switch (typeParameterDeclaration.Variance) {
case VarianceModifier.Invariant:
break;
case VarianceModifier.Covariant:
WriteKeyword(TypeParameterDeclaration.OutVarianceKeywordRole);
break;
case VarianceModifier.Contravariant:
WriteKeyword(TypeParameterDeclaration.InVarianceKeywordRole);
break;
default:
throw new NotSupportedException ("Invalid value for VarianceModifier");
}
typeParameterDeclaration.NameToken.AcceptVisitor(this);
EndNode(typeParameterDeclaration);
}
示例3: VisitTypeParameterDeclaration
public virtual void VisitTypeParameterDeclaration (TypeParameterDeclaration typeParameterDeclaration)
{
VisitChildren (typeParameterDeclaration);
}
示例4: AddTypeParameters
void AddTypeParameters(AstNode parent, MemberName memberName)
{
if (memberName == null || memberName.TypeParameters == null)
return;
var chevronLocs = LocationsBag.GetLocations(memberName.TypeParameters);
if (chevronLocs != null)
parent.AddChild(new CSharpTokenNode(Convert(chevronLocs [chevronLocs.Count - 2]), Roles.LChevron), Roles.LChevron);
for (int i = 0; i < memberName.TypeParameters.Count; i++) {
if (chevronLocs != null && i > 0 && i - 1 < chevronLocs.Count)
parent.AddChild(new CSharpTokenNode(Convert(chevronLocs [i - 1]), Roles.Comma), Roles.Comma);
var arg = memberName.TypeParameters [i];
if (arg == null)
continue;
var tp = new TypeParameterDeclaration();
List<Location> varianceLocation;
switch (arg.Variance) {
case Variance.Contravariant:
tp.Variance = VarianceModifier.Contravariant;
varianceLocation = LocationsBag.GetLocations(arg);
if (varianceLocation != null)
tp.AddChild(new CSharpTokenNode(Convert(varianceLocation [0]), TypeParameterDeclaration.InVarianceKeywordRole), TypeParameterDeclaration.InVarianceKeywordRole);
break;
case Variance.Covariant:
tp.Variance = VarianceModifier.Covariant;
varianceLocation = LocationsBag.GetLocations(arg);
if (varianceLocation != null)
tp.AddChild(new CSharpTokenNode(Convert(varianceLocation [0]), TypeParameterDeclaration.OutVarianceKeywordRole), TypeParameterDeclaration.OutVarianceKeywordRole);
break;
default:
tp.Variance = VarianceModifier.Invariant;
break;
}
AddAttributeSection(tp, arg.OptAttributes);
switch (arg.Variance) {
case Variance.Covariant:
tp.Variance = VarianceModifier.Covariant;
break;
case Variance.Contravariant:
tp.Variance = VarianceModifier.Contravariant;
break;
}
tp.AddChild(Identifier.Create(arg.Name, Convert(arg.Location)), Roles.Identifier);
parent.AddChild(tp, Roles.TypeParameter);
}
if (chevronLocs != null)
parent.AddChild(new CSharpTokenNode(Convert(chevronLocs [chevronLocs.Count - 1]), Roles.RChevron), Roles.RChevron);
}
示例5: AddTypeParameters
void AddTypeParameters (AstNode parent, Mono.CSharp.TypeArguments typeArguments)
{
if (typeArguments == null || typeArguments.IsEmpty)
return;
var chevronLocs = LocationsBag.GetLocations (typeArguments);
if (chevronLocs != null)
parent.AddChild (new CSharpTokenNode (Convert (chevronLocs[chevronLocs.Count - 2]), 1), InvocationExpression.Roles.LChevron);
for (int i = 0; i < typeArguments.Count; i++) {
if (chevronLocs != null && i > 0 && i - 1 < chevronLocs.Count)
parent.AddChild (new CSharpTokenNode (Convert (chevronLocs[i - 1]), 1), InvocationExpression.Roles.Comma);
var arg = (TypeParameterName)typeArguments.Args[i];
if (arg == null)
continue;
TypeParameterDeclaration tp = new TypeParameterDeclaration();
List<Location> varianceLocation;
switch (arg.Variance) {
case Variance.Contravariant:
tp.Variance = VarianceModifier.Contravariant;
varianceLocation = LocationsBag.GetLocations (arg);
if (varianceLocation != null)
tp.AddChild (new CSharpTokenNode (Convert (varianceLocation[0]), "out".Length), TypeParameterDeclaration.VarianceRole);
break;
case Variance.Covariant:
tp.Variance = VarianceModifier.Covariant;
varianceLocation = LocationsBag.GetLocations (arg);
if (varianceLocation != null)
tp.AddChild (new CSharpTokenNode (Convert (varianceLocation[0]), "out".Length), TypeParameterDeclaration.VarianceRole);
break;
default:
tp.Variance = VarianceModifier.Invariant;
break;
}
AddAttributeSection (tp, arg.OptAttributes);
switch (arg.Variance) {
case Variance.Covariant:
tp.Variance = VarianceModifier.Covariant;
break;
case Variance.Contravariant:
tp.Variance = VarianceModifier.Contravariant;
break;
}
tp.AddChild (Identifier.Create (arg.Name, Convert (arg.Location)), InvocationExpression.Roles.Identifier);
parent.AddChild (tp, InvocationExpression.Roles.TypeParameter);
}
if (chevronLocs != null)
parent.AddChild (new CSharpTokenNode (Convert (chevronLocs[chevronLocs.Count - 1]), 1), InvocationExpression.Roles.RChevron);
}
示例6: HandleVisitorTypeParameterDeclarationVisited
void HandleVisitorTypeParameterDeclarationVisited (TypeParameterDeclaration node, InspectionData data)
{
foreach (var rule in policy.Rules) {
if (rule.CheckTypeParameter (node, data))
return;
}
}
示例7: AddTypeParameters
void AddTypeParameters (AstNode parent, List<Location> location, Mono.CSharp.TypeArguments typeArguments)
{
if (typeArguments == null || typeArguments.IsEmpty)
return;
for (int i = 0; i < typeArguments.Count; i++) {
if (location != null && i > 0 && i - 1 < location.Count)
parent.AddChild (new CSharpTokenNode (Convert (location[i - 1]), 1), InvocationExpression.Roles.Comma);
var arg = (TypeParameterName)typeArguments.Args[i];
if (arg == null)
continue;
TypeParameterDeclaration tp = new TypeParameterDeclaration();
// TODO: attributes
switch (arg.Variance) {
case Variance.Covariant:
tp.Variance = VarianceModifier.Covariant;
break;
case Variance.Contravariant:
tp.Variance = VarianceModifier.Contravariant;
break;
}
tp.AddChild (Identifier.Create (arg.Name, Convert (arg.Location)), InvocationExpression.Roles.Identifier);
parent.AddChild (tp, InvocationExpression.Roles.TypeParameter);
}
}
示例8: ConvertTypeParameter
TypeParameterDeclaration ConvertTypeParameter(ITypeParameter tp)
{
TypeParameterDeclaration decl = new TypeParameterDeclaration();
decl.Variance = tp.Variance;
decl.Name = tp.Name;
return decl;
}
示例9: VisitTypeParameterDeclaration
public override void VisitTypeParameterDeclaration(TypeParameterDeclaration typeParameterDeclaration)
{
base.VisitTypeParameterDeclaration(typeParameterDeclaration);
CheckNamedResolveResult(null, typeParameterDeclaration, AffectedEntity.TypeParameter, typeParameterDeclaration.NameToken, Modifiers.None);
}
示例10: MakeTypeParameters
IEnumerable<TypeParameterDeclaration> MakeTypeParameters(IEnumerable<GenericParameter> genericParameters)
{
foreach (var gp in genericParameters) {
TypeParameterDeclaration tp = new TypeParameterDeclaration();
tp.Name = CleanName(gp.Name);
if (gp.IsContravariant)
tp.Variance = VarianceModifier.Contravariant;
else if (gp.IsCovariant)
tp.Variance = VarianceModifier.Covariant;
ConvertCustomAttributes(tp, gp);
yield return tp;
}
}
示例11: AddTypeParameters
void AddTypeParameters (AstNode parent, List<Location> location, Mono.CSharp.TypeArguments typeArguments)
{
if (typeArguments == null || typeArguments.IsEmpty)
return;
for (int i = 0; i < typeArguments.Count; i++) {
if (location != null && i > 0 && i - 1 < location.Count)
parent.AddChild (new CSharpTokenNode (Convert (location[i - 1]), 1), InvocationExpression.Roles.Comma);
var arg = (TypeParameterName)typeArguments.Args[i];
if (arg == null)
continue;
TypeParameterDeclaration tp = new TypeParameterDeclaration();
// TODO: attributes
if (arg.Variance != Variance.None)
throw new NotImplementedException(); // TODO: variance
tp.AddChild (new Identifier (arg.Name, Convert (arg.Location)), InvocationExpression.Roles.Identifier);
parent.AddChild (tp, InvocationExpression.Roles.TypeParameter);
}
}
示例12: ConvertTypeParameter
TypeParameterDeclaration ConvertTypeParameter(ITypeParameter tp)
{
TypeParameterDeclaration decl = new TypeParameterDeclaration();
decl.Variance = tp.Variance;
decl.Name = tp.Name;
if (ShowAttributes)
decl.Attributes.AddRange (tp.Attributes.Select ((a) => new AttributeSection (ConvertAttribute (a))));
return decl;
}
示例13: VisitTypeParameterDeclaration
public void VisitTypeParameterDeclaration(TypeParameterDeclaration typeParameterDeclaration)
{
JsonObject declaration = new JsonObject();
declaration.Comment = "VisitTypeParameterDeclaration";
declaration.AddJsonValue("attributes", GetAttributes(typeParameterDeclaration.Attributes));
switch (typeParameterDeclaration.Variance)
{
case VarianceModifier.Invariant:
break;
case VarianceModifier.Covariant:
declaration.AddJsonValue("keyword", GetKeyword(TypeParameterDeclaration.OutVarianceKeywordRole));
break;
case VarianceModifier.Contravariant:
declaration.AddJsonValue("keyword", GetKeyword(TypeParameterDeclaration.InVarianceKeywordRole));
break;
default:
throw new NotSupportedException("Invalid value for VarianceModifier");
}
declaration.AddJsonValue("identifier", GetIdentifier(typeParameterDeclaration.NameToken));
Push(declaration);
}
示例14: VisitTypeParameterDeclaration
public void VisitTypeParameterDeclaration(TypeParameterDeclaration node)
{
VisitChildren(node);
}
示例15: VisitTypeParameterDeclaration
public virtual void VisitTypeParameterDeclaration(TypeParameterDeclaration typeParameterDeclaration)
{
//throw this.CreateException(typeParameterDeclaration);
}