本文整理汇总了C#中ParameterDeclaration类的典型用法代码示例。如果您正苦于以下问题:C# ParameterDeclaration类的具体用法?C# ParameterDeclaration怎么用?C# ParameterDeclaration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ParameterDeclaration类属于命名空间,在下文中一共展示了ParameterDeclaration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CompileTimeValidate
public override void CompileTimeValidate(ParameterDeclaration parameter, Type memberType, IMessageSink messages)
{
base.CompileTimeValidate(parameter, memberType, messages);
bool isString = memberType == typeof(string);
if (!isString)
{
messages.Write(new Message(
SeverityType.Error,
"PatternAttribute_TypeNotSupported",
string.Format(CultureInfo.InvariantCulture, "The type '{0}' is not a string to perform the expression validation on.", memberType.Name),
GetType().FullName
));
}
if (string.IsNullOrEmpty(expression))
{
messages.Write(new Message(
SeverityType.Error,
"PatternAttribute_PatternNotNullOrEmpty",
"The expression pattern must not be null or empty.",
GetType().FullName
));
}
}
示例2: HandleVisitorParameterDeclarationVisited
void HandleVisitorParameterDeclarationVisited (ParameterDeclaration node, InspectionData data)
{
foreach (var rule in policy.Rules) {
if (rule.CheckParameter (node, data))
return;
}
}
示例3: ParameterValueToken
/// <summary>
/// Initializes a new instance of the <see cref="ParameterValueToken"/> class
/// with the specified parameter.
/// </summary>
/// <param name="parameter">Parameter whose value the token expands to.</param>
/// <exception cref="ArgumentNullException"><paramref name="parameter"/> is <see langword="null"/>.</exception>
public ParameterValueToken(ParameterDeclaration parameter)
{
if (parameter == null) {
throw new ArgumentNullException("parameter");
}
this.parameter = parameter;
}
示例4: ReturnValueToken
/// <summary>
/// Initializes a new instance of the <see cref="ReturnValueToken"/> class
/// with the specified return parameter metadata.
/// </summary>
/// <param name="returnParameter">Return parameter metadata.</param>
/// <exception cref="ArgumentNullException"><paramref name="returnParameter"/> is <see langword="null"/>.</exception>
public ReturnValueToken(ParameterDeclaration returnParameter)
{
if (returnParameter == null) {
throw new ArgumentNullException("returnParameter");
}
this.returnParameter = returnParameter;
}
示例5: VisitParameterDeclaration
public override object VisitParameterDeclaration(ParameterDeclaration parameterDeclaration, object data)
{
if (parameterDeclaration.ParameterModifier == ParameterModifier.Params)
{
UnlockWith(parameterDeclaration);
}
return base.VisitParameterDeclaration(parameterDeclaration, data);
}
示例6: AssertInvocationExpression
protected override void AssertInvocationExpression(InvocationExpression invocation, ParameterDeclaration parameter)
{
foreach (var member in invocation.Descendants.OfType<MemberReferenceExpression>())
{
if (member.MemberName == "LoadDocument")
throw new InvalidOperationException("Reduce cannot contain LoadDocument() methods.");
}
base.AssertInvocationExpression(invocation, parameter);
}
示例7: VisitParameterDeclaration
public override void VisitParameterDeclaration (ParameterDeclaration parameterDeclaration)
{
base.VisitParameterDeclaration (parameterDeclaration);
if (parameterDeclaration.Parent is ConstructorDeclaration)
return;
if (HidesMember (ctx, parameterDeclaration, parameterDeclaration.Name))
AddIssue (parameterDeclaration.NameToken,
ctx.TranslateString ("Parameter has the same name as a member and hides it"));
}
示例8: VisitParameterDeclaration
public override void VisitParameterDeclaration (ParameterDeclaration parameterDeclaration)
{
base.VisitParameterDeclaration (parameterDeclaration);
var resolveResult = ctx.Resolve (parameterDeclaration) as LocalResolveResult;
if (resolveResult == null)
return;
if (!TestOnlyAssigned (ctx, unit, resolveResult.Variable))
return;
AddIssue (parameterDeclaration.NameToken,
ctx.TranslateString ("Parameter is assigned by its value is never used"));
}
示例9: MakeParameters
public static IEnumerable<ParameterDeclaration> MakeParameters(IEnumerable<ParameterDefinition> paramCol)
{
foreach(ParameterDefinition paramDef in paramCol) {
ParameterDeclaration astParam = new ParameterDeclaration();
astParam.Type = ConvertType(paramDef.ParameterType, paramDef);
astParam.Name = paramDef.Name;
if (!paramDef.IsIn && paramDef.IsOut) astParam.ParameterModifier = ParameterModifier.Out;
if (paramDef.IsIn && paramDef.IsOut) astParam.ParameterModifier = ParameterModifier.Ref;
// TODO: params, this
yield return astParam;
}
}
示例10: VisitParameterDeclaration
public override void VisitParameterDeclaration (ParameterDeclaration parameterDeclaration)
{
base.VisitParameterDeclaration (parameterDeclaration);
if (!(parameterDeclaration.Parent is MethodDeclaration))
return;
var resolveResult = ctx.Resolve (parameterDeclaration) as LocalResolveResult;
if (resolveResult == null)
return;
if (FindUsage (ctx, unit, resolveResult.Variable, parameterDeclaration))
return;
AddIssue (parameterDeclaration.NameToken, ctx.TranslateString ("Parameter is never used"));
}
示例11: VisitParameterDeclaration
public override void VisitParameterDeclaration(ParameterDeclaration parameterDeclaration)
{
base.VisitParameterDeclaration(parameterDeclaration);
var resolveResult = ctx.Resolve(parameterDeclaration) as LocalResolveResult;
if (resolveResult == null)
return;
var parameterModifier = parameterDeclaration.ParameterModifier;
if (parameterModifier == ParameterModifier.Out || parameterModifier == ParameterModifier.Ref ||
!TestOnlyAssigned(ctx, parameterDeclaration.Parent, resolveResult.Variable)) {
return;
}
AddIssue(parameterDeclaration.NameToken,
ctx.TranslateString("Parameter is assigned but its value is never used"));
}
示例12: CompileTimeValidate
public override void CompileTimeValidate(ParameterDeclaration parameter, Type memberType, IMessageSink messages)
{
base.CompileTimeValidate(parameter, memberType, messages);
if(exception != null)
{
if(!ValidateExceptionTypeIsException(messages))
{
return;
}
if(!ValidateExceptionTypeCanBeInstantiated(messages))
{
return;
}
}
}
示例13: VisitParameterDeclaration
public override void VisitParameterDeclaration (ParameterDeclaration parameterDeclaration)
{
base.VisitParameterDeclaration (parameterDeclaration);
if (parameterDeclaration.ParameterModifier == ParameterModifier.Out ||
parameterDeclaration.ParameterModifier == ParameterModifier.Ref)
return;
var resolveResult = ctx.Resolve (parameterDeclaration) as LocalResolveResult;
BlockStatement rootStatement = null;
if (parameterDeclaration.Parent is MethodDeclaration) {
rootStatement = ((MethodDeclaration)parameterDeclaration.Parent).Body;
} else if (parameterDeclaration.Parent is AnonymousMethodExpression) {
rootStatement = ((AnonymousMethodExpression)parameterDeclaration.Parent).Body;
} else if (parameterDeclaration.Parent is LambdaExpression) {
rootStatement = ((LambdaExpression)parameterDeclaration.Parent).Body as BlockStatement;
}
CollectIssues (parameterDeclaration, rootStatement, resolveResult);
}
示例14: CompileTimeValidate
public override void CompileTimeValidate(ParameterDeclaration parameter, Type memberType, IMessageSink messages)
{
base.CompileTimeValidate(parameter, memberType, messages);
bool isNullable =
!memberType.IsValueType ||
(memberType.IsGenericType && memberType.GetGenericTypeDefinition() == typeof(Nullable<>));
if (!isNullable)
{
messages.Write(new Message(
SeverityType.Error,
"NotNullAttribute_TypeNotNullable",
string.Format(CultureInfo.InvariantCulture, "The type '{0}' is not nullable.", memberType.Name),
GetType().FullName
));
}
}
示例15: CompileTimeValidateParameters
protected override void CompileTimeValidateParameters(MethodDefDeclaration method, IMessageSink messages, ParameterDeclaration firstParameter, ParameterDeclaration secondParameter)
{
base.CompileTimeValidateParameters(method, messages, firstParameter, secondParameter);
if(typeof(IComparable).IsAssignableFrom(firstParameter.ParameterType.GetSystemType(null, null)))
{
firstParameterIsComparable = true;
}
else if(typeof(IComparable).IsAssignableFrom(secondParameter.ParameterType.GetSystemType(null, null)))
{
firstParameterIsComparable = false;
}
else
{
messages.Write(new Message(
SeverityType.Error,
"ComparisonValidatorAttribute_ParametersCantBeCompared",
string.Format(CultureInfo.InvariantCulture, "None of the parameters '{0}' and '{1}' implements IComparable.", firstParameter.Name, secondParameter.Name),
GetType().FullName
));
}
}