internal static DynamicFlagsCustomTypeInfo Create(params bool[] dynamicFlags) { if (dynamicFlags == null || dynamicFlags.Length == 0) { return default(DynamicFlagsCustomTypeInfo); } var builder = ArrayBuilder<bool>.GetInstance(dynamicFlags.Length); builder.AddRange(dynamicFlags); var result = new DynamicFlagsCustomTypeInfo(builder, startIndex: 0); builder.Free(); return result; }
private static CustomTypeInfo MakeCustomTypeInfo(params bool[] flags) { var dynamicFlagsInfo = new DynamicFlagsCustomTypeInfo(new BitArray(flags)); return(new CustomTypeInfo(DynamicFlagsCustomTypeInfo.PayloadTypeId, dynamicFlagsInfo.GetCustomTypeInfoPayload())); }
public static string GetTypeName(this System.Type type, bool[] dynamicFlags = null, bool escapeKeywordIdentifiers = false) { return(type.GetTypeName(DynamicFlagsCustomTypeInfo.Create(dynamicFlags).GetCustomTypeInfo(), escapeKeywordIdentifiers, null)); }
internal static LocalSymbol Create( TypeNameDecoder <PEModuleSymbol, TypeSymbol> typeNameDecoder, MethodSymbol containingMethod, AssemblySymbol sourceAssembly, Alias alias) { var typeName = alias.Type; Debug.Assert(typeName.Length > 0); var type = typeNameDecoder.GetTypeSymbolForSerializedType(typeName); Debug.Assert((object)type != null); ReadOnlyCollection <byte> dynamicFlags; ReadOnlyCollection <string> tupleElementNames; CustomTypeInfo.Decode(alias.CustomTypeInfoId, alias.CustomTypeInfo, out dynamicFlags, out tupleElementNames); // Preserve tuple element names. See https://github.com/dotnet/roslyn/issues/13589. if (dynamicFlags != null) { var flagsBuilder = ArrayBuilder <bool> .GetInstance(); DynamicFlagsCustomTypeInfo.CopyTo(dynamicFlags, flagsBuilder); var dynamicType = DynamicTypeDecoder.TransformTypeWithoutCustomModifierFlags( type, sourceAssembly, RefKind.None, flagsBuilder.ToImmutableAndFree(), checkLength: false); Debug.Assert(dynamicType != null); Debug.Assert(dynamicType != type); type = dynamicType; } var name = alias.FullName; var displayName = alias.Name; switch (alias.Kind) { case DkmClrAliasKind.Exception: return(new ExceptionLocalSymbol(containingMethod, name, displayName, type, ExpressionCompilerConstants.GetExceptionMethodName)); case DkmClrAliasKind.StowedException: return(new ExceptionLocalSymbol(containingMethod, name, displayName, type, ExpressionCompilerConstants.GetStowedExceptionMethodName)); case DkmClrAliasKind.ReturnValue: { int index; PseudoVariableUtilities.TryParseReturnValueIndex(name, out index); Debug.Assert(index >= 0); return(new ReturnValueLocalSymbol(containingMethod, name, displayName, type, index)); } case DkmClrAliasKind.ObjectId: return(new ObjectIdLocalSymbol(containingMethod, type, name, displayName, isWritable: false)); case DkmClrAliasKind.Variable: return(new ObjectIdLocalSymbol(containingMethod, type, name, displayName, isWritable: true)); default: throw ExceptionUtilities.UnexpectedValue(alias.Kind); } }