本文整理汇总了C#中TypeSymbol.ContainsTupleNames方法的典型用法代码示例。如果您正苦于以下问题:C# TypeSymbol.ContainsTupleNames方法的具体用法?C# TypeSymbol.ContainsTupleNames怎么用?C# TypeSymbol.ContainsTupleNames使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TypeSymbol
的用法示例。
在下文中一共展示了TypeSymbol.ContainsTupleNames方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MergeTupleNames
/// <summary>
/// Returns first or a modified version of first with common tuple names from both types.
/// </summary>
internal static TypeSymbol MergeTupleNames(TypeSymbol first, TypeSymbol second)
{
if (first.Equals(second, TypeCompareKind.AllIgnoreOptions & ~TypeCompareKind.IgnoreTupleNames) ||
!first.ContainsTupleNames())
{
return first;
}
Debug.Assert(first.ContainsTuple());
ImmutableArray<string> names1 = CSharpCompilation.TupleNamesEncoder.Encode(first);
ImmutableArray<string> names2 = CSharpCompilation.TupleNamesEncoder.Encode(second);
ImmutableArray<string> mergedNames;
if (names1.IsDefault || names2.IsDefault)
{
mergedNames = default(ImmutableArray<string>);
}
else
{
Debug.Assert(names1.Length == names2.Length);
mergedNames = names1.ZipAsArray(names2, (n1, n2) => string.CompareOrdinal(n1, n2) == 0 ? n1 : null);
if (mergedNames.All(n => n == null))
{
mergedNames = default(ImmutableArray<string>);
}
}
return TupleTypeDecoder.DecodeTupleTypesIfApplicable(first, mergedNames);
}
示例2: MergeTupleNames
/// <summary>
/// Takes the names from the two types, finds the common names, and applies them onto the target.
/// </summary>
internal static TypeSymbol MergeTupleNames(TypeSymbol first, TypeSymbol second, TypeSymbol target, AssemblySymbol corLibrary)
{
if (!target.ContainsTuple() ||
first.Equals(second, TypeCompareKind.IgnoreCustomModifiersAndArraySizesAndLowerBounds | TypeCompareKind.IgnoreDynamic) ||
!target.ContainsTupleNames())
{
return target;
}
ImmutableArray<string> names1 = CSharpCompilation.TupleNamesEncoder.Encode(first);
ImmutableArray<string> names2 = CSharpCompilation.TupleNamesEncoder.Encode(second);
ImmutableArray<string> mergedNames;
if (names1.IsDefault || names2.IsDefault)
{
mergedNames = default(ImmutableArray<string>);
}
else
{
Debug.Assert(names1.Length == names2.Length);
mergedNames = names1.ZipAsArray(names2, (n1, n2) => string.CompareOrdinal(n1, n2) == 0 ? n1 : null);
if (mergedNames.All(n => n == null))
{
mergedNames = default(ImmutableArray<string>);
}
}
return TupleTypeDecoder.DecodeTupleTypesIfApplicable(target, corLibrary, mergedNames);
}