public bool Apply(IFunctionSpecificationAnalyser aNativeFunction, IFunctionAssembler aAssembler) { NamedCType nativeType = aNativeFunction.CurrentParameterType as NamedCType; if (nativeType == null) return false; CSharpType pinvokeArgType; CSharpType managedArgType; switch (nativeType.Name) { case "bool": pinvokeArgType = new CSharpType("bool"){ Attributes = { "MarshalAs(UnmanagedType.I1)" } }; managedArgType = new CSharpType("bool"); break; case "int": pinvokeArgType = managedArgType = new CSharpType("int"); break; case "size_t": pinvokeArgType = managedArgType = new CSharpType("UIntPtr"); break; default: string managedEnumName; if (!iEnumNativeToManagedMappings.TryGetValue(nativeType.Name, out managedEnumName)) { return false; } pinvokeArgType = managedArgType = new CSharpType(managedEnumName); break; } aAssembler.AddPInvokeParameter(pinvokeArgType, aNativeFunction.CurrentParameter.Name, aNativeFunction.CurrentParameter.Name); aAssembler.AddManagedParameter(aNativeFunction.CurrentParameter.Name, managedArgType); aNativeFunction.ConsumeArgument(); return true; }
public bool Apply(IFunctionSpecificationAnalyser aNativeFunction, IFunctionAssembler aFunctionAssembler) { if (aNativeFunction.CurrentParameter != null) { return false; } var namedType = aNativeFunction.ReturnType as NamedCType; if (namedType == null) { return false; } CSharpType pinvokeArgType; CSharpType managedArgType; switch (namedType.Name) { case "bool": pinvokeArgType = new CSharpType("bool"){ Attributes = { "MarshalAs(UnmanagedType.I1)" } }; managedArgType = new CSharpType("bool"); break; case "int": pinvokeArgType = managedArgType = new CSharpType("int"); break; case "sp_uint64": pinvokeArgType = managedArgType = new CSharpType("ulong"); break; default: string managedEnumName; if (!iEnumNativeToManagedMappings.TryGetValue(namedType.Name, out managedEnumName)) { return false; } pinvokeArgType = managedArgType = new CSharpType(managedEnumName); break; } aFunctionAssembler.InsertAtTop(managedArgType.Name + " returnValue;"); aFunctionAssembler.SetPInvokeReturn(pinvokeArgType, "returnValue"); aFunctionAssembler.SetManagedReturn(managedArgType); aFunctionAssembler.InsertAtEnd("return returnValue;"); aNativeFunction.ConsumeReturn(); return true; }
public bool IsAssignableFrom(Type type) { if (CSharpType != null) { return(CSharpType.IsAssignableFrom(type)); } return(false); }
public Parameter(string name, string?description, CSharpType type, Constant?defaultValue, bool isRequired) { Name = name; Description = description; Type = type; DefaultValue = defaultValue; IsRequired = isRequired; }
public ForEachLoop(Token foreachToken, CSharpType type, Token variableToken, Expression listExpression, IList <Executable> loopBody, TopLevelEntity parent) : base(foreachToken, parent) { this.VariableType = type; this.VariableToken = variableToken; this.ListExpression = listExpression; this.Code = loopBody.ToArray(); }
private static ResolvedType[] GetFrameworkConstructorSignature(string typeName) { if (frameworkConstructors == null) { string[] prefixes = new string[] { "", "System.Collections.Generic." }; frameworkConstructors = new Dictionary <string, ResolvedType[]>(); foreach (string line in Util.GetTextResource("TypeMetadata/FrameworkConstructors.txt").Split('\n')) { string tLine = line.Trim(); if (tLine.Length > 0) { if (!tLine.EndsWith(')')) { throw new System.Exception(line); } tLine = tLine.Substring(0, tLine.Length - 1); string[] parts = tLine.Split('('); if (parts.Length != 2) { throw new System.Exception(line); } parts[1] = parts[1].Trim(); string className = parts[0]; ResolvedType classType = ResolvedType.CreateFrameworkType(className); List <CSharpType> argTypes = new List <CSharpType>(); TokenStream tokenStream = new TokenStream("metadata", parts[1], new Dictionary <string, bool>()); while (tokenStream.HasMore) { if (argTypes.Count > 0) { tokenStream.PopExpected(","); } argTypes.Add(CSharpType.Parse(tokenStream)); } ResolvedType[] argResolvedTypes = argTypes .Select(argType => ResolvedType.Create(argType, prefixes, null)) .ToArray(); ResolvedType ctorType = ResolvedType.CreateFunction(classType, argResolvedTypes); if (!frameworkConstructors.ContainsKey(className)) { frameworkConstructors[className] = new ResolvedType[] { ctorType }; } else { List <ResolvedType> ctorTypes = new List <ResolvedType>(frameworkConstructors[className]); ctorTypes.Add(ctorType); frameworkConstructors[className] = ctorTypes.ToArray(); } } } } ResolvedType[] output; return(frameworkConstructors.TryGetValue(typeName, out output) ? output : null); }
public static CodeWriter AppendNullableValue(this CodeWriter writer, CSharpType type) { if (type.IsNullable && type.IsValueType) { writer.Append($".Value"); } return(writer); }
public static void NavigateToType(CSharpTypeIdentifier typeIdentifier) { bool result = false; try { CSharpType currentType = ResolveType(typeIdentifier); if (currentType == null) { return; } var sourceLocations = currentType.SourceLocations; if (sourceLocations == null || sourceLocations.Count == 0) { return; } var location = sourceLocations[0]; if (location.FileName == null || !location.Position.IsValid) { return; } CSRPOSDATA position = new CSRPOSDATA() { LineIndex = location.Position.Line, ColumnIndex = location.Position.Character }; ILangService languageService; CSharpInheritanceAnalyzer.LangService_GetInstance(out languageService); if (languageService == null) { return; } IProject project = null; languageService.OpenSourceFile(project, location.FileName.Value, position); } catch (ApplicationException) { ////_callHierarchy.LanguageService.DisplayErrorMessage(exception.Message); return; } catch (InvalidOperationException) { ////this._callHierarchy.LanguageService.DisplayErrorMessage(exception2.Message); return; } if (!result) { ////NativeMessageId.Create(this._callHierarchy.LanguageService, jrc_StringResource_identifiers.IDS_HIDDEN_DEFINITION, new object[0]).DisplayError(this._callHierarchy.LanguageService); } }
protected Alter(AlterType alter, string table, WhatToAlter whatToAlter, string column, CSharpType dataType, uint size, int digits) { DataTypeToAlter = dataType; Column = column; AlterType = alter; Table = table; WhatToModify = whatToAlter; DataTypeDigitsToAlter = digits; DataTypeSizeToAlter = size; }
public PagingMethod(RestClientMethod method, RestClientMethod?nextPageMethod, string name, string?nextLinkName, string itemName, CSharpType itemType, Diagnostic diagnostics) { Method = method; NextPageMethod = nextPageMethod; Name = name; NextLinkName = nextLinkName; ItemName = itemName; ItemType = itemType; Diagnostics = diagnostics; }
public override int GetHashCode() { unchecked { int hashCode = (CSharpType != null ? CSharpType.GetHashCode() : 0); hashCode = (hashCode * 397) ^ MaxWidthForStrings.GetHashCode(); hashCode = (hashCode * 397) ^ (DecimalPlacesBeforeAndAfter != null ? DecimalPlacesBeforeAndAfter.GetHashCode() : 0); return(hashCode); } }
internal ResolvedType DoTypeLookup(CSharpType type, ParserContext context) { ResolvedType rType = DoTypeLookupFailSilently(type, context); if (rType == null) { throw new ParserException(type.FirstToken, "Could not resolve parent class or interface: " + type.ToString()); } return(rType); }
private void WriteOperation(CodeWriter writer, RestClientMethod operation, bool async) { using var methodScope = writer.AmbientScope(); CSharpType?bodyType = operation.ReturnType; CSharpType?headerModelType = operation.HeaderModel?.Type; CSharpType responseType = bodyType switch { null when headerModelType != null => new CSharpType(typeof(ResponseWithHeaders <>), headerModelType), { } when headerModelType == null => new CSharpType(typeof(Response <>), bodyType), { } => new CSharpType(typeof(ResponseWithHeaders <>), bodyType, headerModelType),
private IEnumerable <PagingMethod> BuildPagingMethods() { foreach (var operation in _operationGroup.Operations) { Paging?paging = operation.Language.Default.Paging; if (paging == null || operation.IsLongRunning) { continue; } foreach (var serviceRequest in operation.Requests) { RestClientMethod method = RestClient.GetOperationMethod(serviceRequest); RestClientMethod?nextPageMethod = RestClient.GetNextOperationMethod(serviceRequest); if (!(method.Responses.SingleOrDefault(r => r.ResponseBody != null)?.ResponseBody is ObjectResponseBody objectResponseBody)) { throw new InvalidOperationException($"Method {method.Name} has to have a return value"); } TypeProvider implementation = objectResponseBody.Type.Implementation; if (!(implementation is ObjectType type)) { throw new InvalidOperationException($"The return type of {method.Name} has to be an object schema to be used in paging"); } string?nextLinkName = paging.NextLinkName; string itemName = paging.ItemName ?? "value"; ObjectTypeProperty itemProperty = type.GetPropertyBySerializedName(itemName); ObjectTypeProperty?nextLinkProperty = null; if (!string.IsNullOrWhiteSpace(nextLinkName)) { nextLinkProperty = type.GetPropertyBySerializedName(nextLinkName); } if (!(itemProperty.SchemaProperty?.Schema is ArraySchema arraySchema)) { throw new InvalidOperationException($"{itemName} property has to be an array schema, actual {itemProperty.SchemaProperty?.Schema}"); } CSharpType itemType = _context.TypeFactory.CreateType(arraySchema.ElementType, false); yield return(new PagingMethod( method, nextPageMethod, method.Name, nextLinkProperty?.Declaration.Name, itemProperty.Declaration.Name, itemType, new Diagnostic($"{Declaration.Name}.{method.Name}"))); } } }
public void Add(OpenApiSchema schema, CSharpType type) { _types.Add(type); string key = schema.Reference?.Id ?? schema.Type; if (!string.IsNullOrEmpty(key)) { _schemas.Add(key, type.Identifier); } }
[ANonOptimize][AInvariant] public static Assembly AllocAssembly(CSharpType key) { Assembly result; if (!_ra.TryGetValue(key.Assembly, out result)) { result = new RuntimeAssembly(key.Assembly); _ra.Add(key.Assembly, result); } return(result); }
public PropertyDefinition( Token firstToken, Dictionary <string, Token> topLevelModifiers, CSharpType type, Token name, TopLevelEntity parent) : base(firstToken, parent) { this.ApplyModifiers(topLevelModifiers); this.Type = type; this.Name = name; }
public ConstDefinition( Token firstToken, Dictionary <string, Token> modifiers, CSharpType constType, Token name, TopLevelEntity parent) : base(firstToken, parent) { this.ApplyModifiers(modifiers); this.Name = name; this.Type = constType; }
public Column(string name, CSharpType type, uint size = 0, int digits = 0, bool notNull = false, bool autoIncrement = false, object defaultValue = null, Constraint constraint = null) { DataType = type; Name = name; Constraint = constraint; NotNull = notNull; Size = size; Digits = digits; DefaultValue = defaultValue; AutoIncrement = autoIncrement; }
private static (bool, string, bool, bool) GetJavaScriptPropertyType(CSharpType csharpType, IEnumerable<CSharpObject> references) { bool isJavaScriptType; bool hasMany = false; bool nullable = false; while (csharpType.GenericArguments.Count == 1) { if (csharpType.Name == "Array`1" || csharpType.NativeType != null && (csharpType.NativeType.Name == "IEnumerable`1" || csharpType.NativeType.GetInterface(typeof(IEnumerable<>).Name) != null)) hasMany = true; if (csharpType.Name == "Nullable`1") nullable = true; csharpType = csharpType.GenericArguments[0]; } string type; var coreType = csharpType.NativeType != null && IsCoreType(csharpType.NativeType); if (coreType) { type = ConvertCoreTypeToJavaScriptType(csharpType.NativeType); isJavaScriptType = true; if (csharpType.NativeType.IsClass) nullable = true; } else { var modelReference = references.FirstOrDefault(x => x.Name == csharpType.Name); if (modelReference != null) { if (modelReference.ObjectType == CSharpObjectType.Enum) { type = "string"; isJavaScriptType = true; } else { type = modelReference.Name; isJavaScriptType = false; } if (modelReference.ObjectType == CSharpObjectType.Class || modelReference.ObjectType == CSharpObjectType.Interface) nullable = true; } else { type = "any"; isJavaScriptType = true; } } if (hasMany) type += "[]"; return (isJavaScriptType, type, hasMany, nullable); }
public ArrayInitialization( Token firstToken, CSharpType itemType, Expression arrayLength, IList <Expression> arrayElements, TopLevelEntity parent) : base(firstToken, parent) { this.ItemType = itemType; this.ArrayLengthExpression = arrayLength; this.ArrayItems = arrayElements == null ? null : arrayElements.ToArray(); }
public XmlObjectSerialization(string name, CSharpType type, XmlObjectElementSerialization[] elements, XmlObjectAttributeSerialization[] attributes, XmlObjectArraySerialization[] embeddedArrays) { Type = type; Elements = elements; Attributes = attributes; Name = name; EmbeddedArrays = embeddedArrays; }
public static void WriteConversion(this CodeWriter writer, CSharpType from, CSharpType to) { if (to.IsFrameworkType && from.IsFrameworkType) { if ((to.FrameworkType == typeof(IList <>) || to.FrameworkType == typeof(IReadOnlyList <>)) && from.FrameworkType == typeof(IEnumerable <>)) { writer.UseNamespace(typeof(Enumerable).Namespace !); writer.Append($".ToArray()"); } } }
private void WriteStartOperationOperation(CodeWriter writer, LongRunningOperationMethod lroMethod, bool async) { RestClientMethod originalMethod = lroMethod.StartMethod; CSharpType returnType = async ? new CSharpType(typeof(Task <>), lroMethod.Operation.Type) : lroMethod.Operation.Type; Parameter[] parameters = originalMethod.Parameters; writer.WriteXmlDocumentationSummary(originalMethod.Description); foreach (Parameter parameter in parameters) { writer.WriteXmlDocumentationParameter(parameter.Name, parameter.Description); } writer.WriteXmlDocumentationParameter("cancellationToken", "The cancellation token to use."); string asyncText = async ? "async " : string.Empty; writer.Append($"public virtual {asyncText}{returnType} {CreateStartOperationName(lroMethod.Name, async)}("); foreach (Parameter parameter in parameters) { writer.WriteParameter(parameter); } writer.Line($"{typeof(CancellationToken)} cancellationToken = default)"); using (writer.Scope()) { writer.WriteParameterNullChecks(parameters); WriteDiagnosticScope(writer, lroMethod.Diagnostics, writer => { string awaitText = async ? "await" : string.Empty; string configureText = async ? ".ConfigureAwait(false)" : string.Empty; writer.Append($"var originalResponse = {awaitText} RestClient.{CreateMethodName(originalMethod.Name, async)}("); foreach (Parameter parameter in parameters) { writer.Append($"{parameter.Name}, "); } writer.Line($"cancellationToken){configureText};"); writer.Append($"return new {lroMethod.Operation.Type}({ClientDiagnosticsField}, {PipelineField}, RestClient.{CreateRequestMethodName(originalMethod.Name)}("); foreach (Parameter parameter in parameters) { writer.Append($"{parameter.Name}, "); } writer.RemoveTrailingComma(); writer.Line($").Request, originalResponse);"); }); } writer.Line(); }
public ObjectSerialization Build(KnownMediaType mediaType, Schema schema, CSharpType type) { switch (mediaType) { case KnownMediaType.Json: return(BuildSerialization(schema, type)); case KnownMediaType.Xml: return(BuildXmlElementSerialization(schema, type, schema.XmlName ?? schema.Name, true)); default: throw new NotImplementedException(mediaType.ToString()); } }
public override object[] GetCustomAttributes(Type attributeType, bool inherit) { CSharpType attType = ((RuntimeType)attributeType).type; List <object> list = new List <object>(); foreach (var item in member.Attributes) { if (item.Type == attType && (inherit || item.DefiningObject == member)) { list.Add(item); } } return(list.ToArray()); }
public bool Apply(IFunctionSpecificationAnalyser aNativeFunction, IFunctionAssembler aFunctionAssembler) { if (aNativeFunction.CurrentParameter != null) { return(false); } var namedType = aNativeFunction.ReturnType as NamedCType; if (namedType == null) { return(false); } CSharpType pinvokeArgType; CSharpType managedArgType; switch (namedType.Name) { case "bool": pinvokeArgType = new CSharpType("bool") { Attributes = { "MarshalAs(UnmanagedType.I1)" } }; managedArgType = new CSharpType("bool"); break; case "int": pinvokeArgType = managedArgType = new CSharpType("int"); break; case "sp_uint64": pinvokeArgType = managedArgType = new CSharpType("ulong"); break; default: string managedEnumName; if (!iEnumNativeToManagedMappings.TryGetValue(namedType.Name, out managedEnumName)) { return(false); } pinvokeArgType = managedArgType = new CSharpType(managedEnumName); break; } aFunctionAssembler.InsertAtTop(managedArgType.Name + " returnValue;"); aFunctionAssembler.SetPInvokeReturn(pinvokeArgType, "returnValue"); aFunctionAssembler.SetManagedReturn(managedArgType); aFunctionAssembler.InsertAtEnd("return returnValue;"); aNativeFunction.ConsumeReturn(); return(true); }
[ANonOptimize][AInvariant] public static RuntimeType FromType(CSharpType key) { if (key == null) { throw new ArgumentNullException(); } RuntimeType result; if (!_rt.TryGetValue(key, out result)) { result = new RuntimeType(key); _rt.Add(key, result); } return(result); }
private Constant?ParseConstant(RequestParameter parameter) { if (parameter.ClientDefaultValue != null) { CSharpType constantTypeReference = _context.TypeFactory.CreateType(parameter.Schema, parameter.IsNullable()); return(BuilderHelpers.ParseConstant(parameter.ClientDefaultValue, constantTypeReference)); } if (parameter.Schema is ConstantSchema constantSchema) { return(ParseConstant(constantSchema)); } return(null); }
public IEnumerable <string> GetAttributes() { if (CSharpType.Equals("string")) { if (Size.HasValue) { yield return($"[MaxLength({Size})]"); } if (!IsNullable) { yield return($"[Required]"); } } }
public override MethodInfo MakeGenericMethod(params Type[] typeArguments) { var typeParameters = member.TypeParameters; if (typeParameters.Count != typeArguments.Length || typeParameters.Count == 0) { return(null); } CSharpType[] types = new CSharpType[typeArguments.Length]; for (int i = 0; i < types.Length; i++) { types[i] = ((RuntimeType)typeArguments[i]).type; } return(new RuntimeMethodInfo(new MemberWithTypeArguments(member, types))); }
private static void AddOverrides(CSharpType declaringType, Method method) { foreach (var inheritanceRelationship in declaringType.BaseTypeRelationships) { var baseType = inheritanceRelationship.BaseType; foreach (var declaredMethod in baseType.DeclaredMethods) { if (declaredMethod.SignatureEquals(method)) { baseType.OverrideOccurrences.Add(method); } } AddOverrides(baseType, method); } }
public void Visit(Document document) { foreach (var definition in document.Definitions) { var csharpType = new CSharpType(documentContext.Namespace, TemplateContextGenerator.MangleCSharpTypeName(definition.Name), csharpNamespace); if (definition is Struct) { csharpType.IsTripStruct = true; } else if (definition is IntegerEnum) { csharpType.IsTripEnum = true; } LOG.Debug(string.Format("Registering type '{0}'", csharpType)); documentContext.TypeRegistry.Add(csharpType); } }
public bool TryGetTypeReference(CSharpType semanticType, out ITypeReference cciType) { Contract.Ensures(!Contract.Result<bool>() || Contract.ValueAtReturn(out cciType) != null && semanticType != null); cciType = null; #region Check input if (semanticType == null) { return false; } #endregion #region Check cache if (VSServiceProvider.Current.VSOptionsPage.Caching) if (_semanticTypesToCCITypes.TryGetValue(semanticType, out cciType)) return cciType != null && cciType != Dummy.TypeReference; #endregion #region Get assembly reference IAssemblyReference cciAssembly; if (!TryGetAssemblyReference(semanticType.Assembly, out cciAssembly)) goto ReturnFalse; #endregion return TryGetTypeReference(semanticType, cciAssembly, out cciType); #region ReturnFalse: ReturnFalse: if (VSServiceProvider.Current.VSOptionsPage.Caching) _semanticTypesToCCITypes[semanticType] = Dummy.TypeReference; return false; #endregion }
/// <summary>构造函数</summary> /// <param name="FieldName">字段名称</param> /// <param name="FieldType">类型</param> /// <param name="QueryString">查询条件</param> public QueryFieldInfo(String FieldName, CSharpType FieldType, String QueryString) { this.FieldName = FieldName; this.FieldType = FieldType; this.QueryString = QueryString; }
public bool TryGetTypeReference(CSharpType semanticType, IAssemblyReference cciAssembly, out ITypeReference cciType) { Contract.Ensures(!Contract.Result<bool>() || (Contract.ValueAtReturn(out cciType) != null)); cciType = null; #region Check input if (semanticType == null || cciAssembly == null) { return false; } #endregion #region Check cache if (VSServiceProvider.Current.VSOptionsPage.Caching) if (_semanticTypesToCCITypes.TryGetValue(semanticType, out cciType)) return cciType != null && cciType != Dummy.TypeReference; #endregion #region If generic if (semanticType.TypeArguments != null && semanticType.TypeArguments.Count > 0) { var genericArguments = new List<ITypeReference>(); foreach (var semanticTypeArg in semanticType.TypeArguments) { if (semanticTypeArg == null) goto ReturnFalse; ITypeReference cciTypeArg = null; if (TryGetTypeReference(semanticTypeArg, out cciTypeArg)) { genericArguments.Add(cciTypeArg); } else { goto ReturnFalse; } } ITypeReference genericType = null; if (!TryGetTypeReference(semanticType.DefiningType, out genericType)) { goto ReturnFalse; } cciType = new Microsoft.Cci.MutableCodeModel.GenericTypeInstanceReference() { InternFactory = this.Host.InternFactory, GenericArguments = genericArguments, GenericType = (INamedTypeReference) genericType, }; goto ReturnTrue; } #endregion #region If array if (semanticType.IsArray) { ITypeReference eleType; if (!TryGetTypeReference(semanticType.ElementType, out eleType)) goto ReturnFalse; if (semanticType.ElementType.IsArray) { Contract.Assume(semanticType.Rank > 0); cciType = new Microsoft.Cci.MutableCodeModel.MatrixTypeReference() { ElementType = eleType, InternFactory = this.Host.InternFactory, Rank = (uint)semanticType.Rank }; goto ReturnTrue; } else { cciType = new Microsoft.Cci.MutableCodeModel.VectorTypeReference() { ElementType = eleType, InternFactory = this.Host.InternFactory, }; goto ReturnTrue; } } #endregion #region If type parameter if (semanticType.IsTypeParameter) { if (semanticType.DefiningMember != null) { cciType = new Microsoft.Cci.MutableCodeModel.GenericMethodParameterReference() { Index = (ushort)(semanticType.DefiningMember.TypeParameters != null? semanticType.DefiningMember.TypeParameters.IndexOf(semanticType) : 0), InternFactory = this.Host.InternFactory, Name = Host.NameTable.GetNameFor(semanticType.Name != null ? semanticType.Name.Text : "T"), }; goto ReturnTrue; } else if (semanticType.DefiningType != null) { ITypeReference cciDefiningType; if (!TryGetTypeReference(semanticType.DefiningType, out cciDefiningType)) goto ReturnFalse; cciType = new Microsoft.Cci.MutableCodeModel.GenericTypeParameterReference() { DefiningType = cciDefiningType, Index = (ushort)(semanticType.DefiningType.TypeParameters != null ? semanticType.DefiningType.TypeParameters.IndexOf(semanticType) : 0), InternFactory = this.Host.InternFactory, Name = Host.NameTable.GetNameFor(semanticType.Name != null ? semanticType.Name.Text : "T"), }; goto ReturnTrue; } } #endregion #region If namespace type if (semanticType.ContainingType == null) { IUnitNamespaceReference cciNamespace; var namespaceName = semanticType.ContainingNamespace; if (namespaceName == null || !TryGetNamespaceReference(namespaceName, cciAssembly, out cciNamespace)) { cciNamespace = new Microsoft.Cci.MutableCodeModel.RootUnitNamespaceReference() { Unit = cciAssembly }; } if (semanticType.ContainingType == null) { if (semanticType.Name == null || semanticType.Name.Text == null) goto ReturnFalse; cciType = new Microsoft.Cci.MutableCodeModel.NamespaceTypeReference() { ContainingUnitNamespace = cciNamespace, GenericParameterCount = (ushort) (semanticType.TypeParameters == null ? 0 : semanticType.TypeParameters.Count), InternFactory = Host.InternFactory, IsValueType = semanticType.IsValueType, IsEnum = semanticType.IsEnum, Name = Host.NameTable.GetNameFor(semanticType.Name.Text), TypeCode = CSharpToCCIHelper.GetPrimitiveTypeCode(semanticType), }; goto ReturnTrue; } } #endregion #region If nested type if (semanticType.ContainingType != null) { ITypeReference containingType; if (!TryGetTypeReference(semanticType.ContainingType, cciAssembly, out containingType)) goto ReturnFalse; if (semanticType.Name == null || semanticType.Name.Text == null) goto ReturnFalse; cciType = new Microsoft.Cci.MutableCodeModel.NestedTypeReference() { ContainingType = containingType, GenericParameterCount = (ushort)(semanticType.TypeParameters == null ? 0 : semanticType.TypeParameters.Count), InternFactory = this.Host.InternFactory, MangleName = true, Name = Host.NameTable.GetNameFor(semanticType.Name.Text) }; goto ReturnTrue; } #endregion #region ReturnTrue: ReturnTrue: if (VSServiceProvider.Current.VSOptionsPage.Caching) _semanticTypesToCCITypes[semanticType] = cciType; return true; #endregion #region ReturnFalse: ReturnFalse: VSServiceProvider.Current.Logger.WriteToLog("Failed to build type reference for: " + (semanticType.Name != null ? semanticType.Name.Text : semanticType.ToString())); if (VSServiceProvider.Current.VSOptionsPage.Caching) _semanticTypesToCCITypes[semanticType] = Dummy.TypeReference; return false; #endregion }