本文整理汇总了C#中TypeSymbol.ToTestDisplayString方法的典型用法代码示例。如果您正苦于以下问题:C# TypeSymbol.ToTestDisplayString方法的具体用法?C# TypeSymbol.ToTestDisplayString怎么用?C# TypeSymbol.ToTestDisplayString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TypeSymbol
的用法示例。
在下文中一共展示了TypeSymbol.ToTestDisplayString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestBinaryIntrinsicSymbol
//.........这里部分代码省略.........
{
Assert.Null(symbol3);
}
if (!leftType.IsDynamic())
{
Assert.Null(symbol4);
}
return;
}
}
else if ((op == BinaryOperatorKind.Equal || op == BinaryOperatorKind.NotEqual) &&
leftType != rightType &&
(!leftType.IsValueType || !rightType.IsValueType ||
leftType.SpecialType == SpecialType.System_Boolean || rightType.SpecialType == SpecialType.System_Boolean ||
(leftType.SpecialType == SpecialType.System_Decimal && (rightType.SpecialType == SpecialType.System_Double || rightType.SpecialType == SpecialType.System_Single)) ||
(rightType.SpecialType == SpecialType.System_Decimal && (leftType.SpecialType == SpecialType.System_Double || leftType.SpecialType == SpecialType.System_Single))) &&
(!leftType.IsReferenceType || !rightType.IsReferenceType ||
!compilation.Conversions.ClassifyConversion(leftType, rightType, ref useSiteDiagnostics).IsReference))
{
Assert.Null(symbol1);
Assert.Null(symbol2);
Assert.Null(symbol3);
Assert.Null(symbol4);
return;
}
else
{
signature = compilation.builtInOperators.GetSignature(result);
}
Assert.NotNull(symbol1);
string containerName = signature.LeftType.ToTestDisplayString();
string leftName = containerName;
string rightName = signature.RightType.ToTestDisplayString();
string returnName = signature.ReturnType.ToTestDisplayString();
if (isDynamic)
{
containerName = compilation.DynamicType.ToTestDisplayString();
}
else if (op == BinaryOperatorKind.Addition || op == BinaryOperatorKind.Subtraction)
{
if (signature.LeftType.IsObjectType() && signature.RightType.IsStringType())
{
containerName = rightName;
}
else if ((leftType.IsEnumType() || leftType.IsPointerType()) && (rightType.IsIntegralType() || rightType.IsCharType()))
{
containerName = leftType.ToTestDisplayString();
leftName = containerName;
returnName = containerName;
}
else if ((rightType.IsEnumType() || rightType.IsPointerType()) && (leftType.IsIntegralType() || leftType.IsCharType()))
{
containerName = rightType.ToTestDisplayString();
rightName = containerName;
returnName = containerName;
}
}
Assert.Equal(isDynamic, signature.ReturnType.IsDynamic());
string expectedSymbol = String.Format("{4} {0}.{2}({1} left, {3} right)",
containerName,
示例2: AssertBaseType
internal static void AssertBaseType(TypeSymbol @base, string name)
{
Assert.NotEqual(SymbolKind.ErrorType, @base.Kind);
Assert.Equal(name, @base.ToTestDisplayString());
}
示例3: TestUnaryIntrinsicSymbol
private void TestUnaryIntrinsicSymbol(
UnaryOperatorKind op,
TypeSymbol type,
CSharpCompilation compilation,
SemanticModel semanticModel,
ExpressionSyntax node1,
ExpressionSyntax node2,
ExpressionSyntax node3,
ExpressionSyntax node4
)
{
SymbolInfo info1 = semanticModel.GetSymbolInfo(node1);
Assert.Equal(type.IsDynamic() ? CandidateReason.LateBound : CandidateReason.None, info1.CandidateReason);
Assert.Equal(0, info1.CandidateSymbols.Length);
var symbol1 = (MethodSymbol)info1.Symbol;
var symbol2 = semanticModel.GetSymbolInfo(node2).Symbol;
var symbol3 = (MethodSymbol)semanticModel.GetSymbolInfo(node3).Symbol;
var symbol4 = semanticModel.GetSymbolInfo(node4).Symbol;
Assert.Equal(symbol1, symbol3);
if ((object)symbol1 != null)
{
Assert.NotSame(symbol1, symbol3);
Assert.Equal(symbol1.GetHashCode(), symbol3.GetHashCode());
Assert.Equal(symbol1.Parameters[0], symbol3.Parameters[0]);
Assert.Equal(symbol1.Parameters[0].GetHashCode(), symbol3.Parameters[0].GetHashCode());
}
Assert.Equal(symbol2, symbol4);
TypeSymbol underlying = type;
if (op == UnaryOperatorKind.BitwiseComplement ||
op == UnaryOperatorKind.PrefixDecrement || op == UnaryOperatorKind.PrefixIncrement ||
op == UnaryOperatorKind.PostfixDecrement || op == UnaryOperatorKind.PostfixIncrement)
{
underlying = type.EnumUnderlyingType();
}
UnaryOperatorKind result = OverloadResolution.UnopEasyOut.OpKind(op, underlying);
UnaryOperatorSignature signature;
if (result == UnaryOperatorKind.Error)
{
if (type.IsDynamic())
{
signature = new UnaryOperatorSignature(op | UnaryOperatorKind.Dynamic, type, type);
}
else if (type.IsPointerType() &&
(op == UnaryOperatorKind.PrefixDecrement || op == UnaryOperatorKind.PrefixIncrement ||
op == UnaryOperatorKind.PostfixDecrement || op == UnaryOperatorKind.PostfixIncrement))
{
signature = new UnaryOperatorSignature(op | UnaryOperatorKind.Pointer, type, type);
}
else
{
Assert.Null(symbol1);
Assert.Null(symbol2);
Assert.Null(symbol3);
Assert.Null(symbol4);
return;
}
}
else
{
signature = compilation.builtInOperators.GetSignature(result);
if ((object)underlying != (object)type)
{
Assert.Equal(underlying, signature.OperandType);
Assert.Equal(underlying, signature.ReturnType);
signature = new UnaryOperatorSignature(signature.Kind, type, type);
}
}
Assert.NotNull(symbol1);
string containerName = signature.OperandType.ToTestDisplayString();
string returnName = signature.ReturnType.ToTestDisplayString();
if (op == UnaryOperatorKind.LogicalNegation && type.IsEnumType())
{
containerName = type.ToTestDisplayString();
returnName = containerName;
}
Assert.Equal(String.Format("{2} {0}.{1}({0} value)",
containerName,
OperatorFacts.UnaryOperatorNameFromOperatorKind(op),
returnName),
symbol1.ToTestDisplayString());
Assert.Equal(MethodKind.BuiltinOperator, symbol1.MethodKind);
Assert.True(symbol1.IsImplicitlyDeclared);
bool expectChecked = false;
//.........这里部分代码省略.........