当前位置: 首页>>代码示例>>C#>>正文


C# ITypeSymbol.GetFullName方法代码示例

本文整理汇总了C#中ITypeSymbol.GetFullName方法的典型用法代码示例。如果您正苦于以下问题:C# ITypeSymbol.GetFullName方法的具体用法?C# ITypeSymbol.GetFullName怎么用?C# ITypeSymbol.GetFullName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ITypeSymbol的用法示例。


在下文中一共展示了ITypeSymbol.GetFullName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetAttribute

      public static AttributeData GetAttribute(this ISymbol symbol, ITypeSymbol attributeType)
      {
         IEnumerable<AttributeData> attributes = symbol.GetAttributes(attributeType);
         if (attributes.Skip(1).Any())
            throw new InvalidOperationException($"Multiple attributes of type {attributeType.GetFullName()} were found on {symbol.Name}.");

         return attributes.FirstOrDefault();

      }
开发者ID:modulexcite,项目名称:AlphaVSX,代码行数:9,代码来源:ISymbolExtensions.cs

示例2: CollectMembers

		public void CollectMembers (ITypeSymbol cls, bool inherited, string topType, ListDictionary properties, ListDictionary events)
		{
			if (cls.GetFullName () == topType)
				return;

			foreach (var prop in cls.GetMembers ().OfType<IPropertySymbol> ())
				if (IsBrowsable (prop))
					properties [prop.Name] = prop;

			foreach (var ev in cls.GetMembers ().OfType<IEventSymbol> ())
				if (IsBrowsable (ev))
					events [ev.Name] = ev;
					
			if (inherited) {
				CollectMembers (cls.BaseType, true, topType, properties, events);
			}
		}
开发者ID:pabloescribanoloza,项目名称:monodevelop,代码行数:17,代码来源:WidgetParser.cs

示例3: GetTypeSize

      private SyntaxNode GetTypeSize(ITypeSymbol type)
      {
         if (type.TypeKind == TypeKind.Enum)
         {
            INamedTypeSymbol enumType = type as INamedTypeSymbol;
            if (enumType == null && enumType.TypeKind == TypeKind.Enum)
               throw new ArgumentException("Not an enum type", "type");

            ITypeSymbol underlyingType = enumType.EnumUnderlyingType;
            if (underlyingType == null)
               throw new ArgumentException("Cannot get underlying type of enum", "type");

            switch (underlyingType.SpecialType)
            {
               case SpecialType.System_Byte:
               case SpecialType.System_SByte:
                  return m_generator.LiteralExpression(1);

               case SpecialType.System_Int16:
               case SpecialType.System_UInt16:
                  return m_generator.LiteralExpression(2);

               case SpecialType.System_Int32:
               case SpecialType.System_UInt32:
                  return m_generator.LiteralExpression(4);

               case SpecialType.System_Int64:
               case SpecialType.System_UInt64:
                  return m_generator.LiteralExpression(8);

               default:
                  throw new NotSupportedException($"Cannot get size of underlying enum type: {underlyingType.GetFullName()}");
            }
         }

         if (type.GetFullName() == typeof(Guid).FullName && type.ContainingAssembly.Name == typeof(Guid).Assembly.GetName().Name)
            return m_generator.LiteralExpression(Marshal.SizeOf<Guid>());
         
         switch (type.SpecialType)
         {
            case SpecialType.System_Boolean:
            case SpecialType.System_SByte:
            case SpecialType.System_Byte:
               return m_generator.LiteralExpression(1);
            case SpecialType.System_Char:
            case SpecialType.System_Int16:
            case SpecialType.System_UInt16:
               return m_generator.LiteralExpression(2);
            case SpecialType.System_Int32:
            case SpecialType.System_UInt32:
               return m_generator.LiteralExpression(4);
            case SpecialType.System_Int64:
            case SpecialType.System_UInt64:
            case SpecialType.System_DateTime:
               return m_generator.LiteralExpression(8);
            case SpecialType.System_Decimal:
               return m_generator.LiteralExpression(System.Runtime.InteropServices.Marshal.SizeOf<decimal>());
            case SpecialType.System_Single:
               return m_generator.LiteralExpression(System.Runtime.InteropServices.Marshal.SizeOf<float>());
            case SpecialType.System_Double:
               return m_generator.LiteralExpression(System.Runtime.InteropServices.Marshal.SizeOf<double>());
            case SpecialType.System_IntPtr:
            case SpecialType.System_UIntPtr:
               ITypeSymbol marshalType = m_compilation.GetTypeByMetadataName(typeof(System.Runtime.InteropServices.Marshal).FullName);
               if (marshalType == null)
                  throw new InvalidOperationException($"Failed to find type of {typeof(System.Runtime.InteropServices.Marshal).FullName}");

               return m_generator.InvocationExpression(
                  m_generator.MemberAccessExpression(
                     m_generator.WithTypeArguments(
                        m_generator.TypeExpression(marshalType),
                        m_generator.TypeExpression(type.SpecialType)
                     ),
                     "SizeOf"
                  )
               );
            default:
               throw new InvalidOperationException($"Unsupported event parameter type {type.GetFullName()} to get size of.");
         }

      }
开发者ID:modulexcite,项目名称:EventSourceGenerator-1,代码行数:81,代码来源:EventSourceGenerator.cs

示例4: Type

        public JsExpression Type(ITypeSymbol type, bool forceUnconstructedScope = false)
        {
            if (type is IArrayTypeSymbol)
            {
                var arrayType = (IArrayTypeSymbol)type;
                var elementType = arrayType.ElementType;
/*
                if (elementType is TypeParameterSymbol && forceUnconstructedScope)
                {
                    var tp = (TypeParameterSymbol)elementType;
                    elementType = Context.Instance.ObjectType;
                }
*/
                return MakeArrayType(elementType);
            }

            var explicitName = type.GetAttributeValue<string>(Context.Instance.JsAttributeType, "Name");
            if (explicitName != null)
                return Js.Reference(explicitName);

            var typeParameter = type as ITypeParameterSymbol;
            if (typeParameter != null && typeParameter.DeclaringType != null)
            {
                return Js.Reference(type.Name);
//                return Js.This().Member(SpecialNames.TypeArgs).Index(Js.Primitive(type.Name));
            }
            var namedTypeSymbol = type as INamedTypeSymbol;
            if (namedTypeSymbol != null)
            {
                if (namedTypeSymbol.HasOrIsEnclosedInGenericParameters() && !forceUnconstructedScope && !namedTypeSymbol.IsUnboundGenericType)
                {
                    return MakeGenericType(namedTypeSymbol);
                }
                else if (type.ContainingType != null && type.ContainingType.GetAttributeValue<string>(Context.Instance.JsAttributeType, "Name") != null)
                {
                    var result = Type(type.ContainingType).Member(type.Name.MaskSpecialCharacters());
                    return result;
                }
                else 
                {
                    var name = type.GetFullName().Replace('`', '$');
                    JsExpression result = Js.Reference(name);
                    return result;
                }
            }
            var typeName = type.GetTypeName();
            return new JsVariableReferenceExpression(typeName);
        }
开发者ID:x335,项目名称:WootzJs,代码行数:48,代码来源:Idioms.cs

示例5: UpdateClass

		void UpdateClass (WidgetParser parser, Stetic.Project stetic, ITypeSymbol widgetClass, ITypeSymbol wrapperClass)
		{
			string typeName = widgetClass.GetFullName();
			string basetypeName = GetBaseType (parser, widgetClass, stetic);
			XmlElement objectElem = (XmlElement) SelectSingleNode ("objects/object[@type='" + typeName + "']");
			
			if (objectElem == null) {
			
				// The widget class is not yet in the XML file. Create an element for it.
				objectElem = CreateElement ("object");
				objectElem.SetAttribute ("type", typeName);
				string category = widgetClass.GetComponentCategory();
				if (category == String.Empty)
					objectElem.SetAttribute ("palette-category", "General");
				else
					objectElem.SetAttribute ("palette-category", category);
				objectElem.SetAttribute ("allow-children", "false");
				if (wrapperClass != null)
					objectElem.SetAttribute ("wrapper", wrapperClass.GetFullName());
				
				// By default add a reference to Gtk.Widget properties and events
				XmlElement itemGroups = objectElem.OwnerDocument.CreateElement ("itemgroups");
				objectElem.AppendChild (itemGroups);
				
				itemGroups = objectElem.OwnerDocument.CreateElement ("signals");
				objectElem.AppendChild (itemGroups);
				
				objectElem.SetAttribute ("base-type", basetypeName);
				DocumentElement.AppendChild (objectElem);
			}
			
			UpdateObject (parser, basetypeName, objectElem, widgetClass, wrapperClass);
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:33,代码来源:ObjectsDocument.cs

示例6: GuessNameFromType

		internal static string GuessNameFromType(ITypeSymbol returnType)
		{
			switch (returnType.SpecialType) {
			case SpecialType.System_Object:
				return "obj";
			case SpecialType.System_Boolean:
				return "b";
			case SpecialType.System_Char:
				return "ch";
			case SpecialType.System_SByte:
			case SpecialType.System_Byte:
				return "b";
			case SpecialType.System_Int16:
			case SpecialType.System_UInt16:
			case SpecialType.System_Int32:
			case SpecialType.System_UInt32:
			case SpecialType.System_Int64:
			case SpecialType.System_UInt64:
				return "i";
			case SpecialType.System_Decimal:
				return "d";
			case SpecialType.System_Single:
				return "f";
			case SpecialType.System_Double:
				return "d";
			case SpecialType.System_String:
				return "str";
			case SpecialType.System_IntPtr:
			case SpecialType.System_UIntPtr:
				return "ptr";
			case SpecialType.System_DateTime:
				return "date";
			}
			if (returnType.TypeKind == TypeKind.Array)
				return "arr";
			switch (returnType.GetFullName()) {
			case "System.Exception":
				return "e";
			case "System.Object":
			case "System.Func":
			case "System.Action":
				return "action";
			}
			return string.IsNullOrEmpty(returnType.Name) ? "obj" : returnType.Name;
		}
开发者ID:pabloescribanoloza,项目名称:monodevelop,代码行数:45,代码来源:RefactoringHelpers.cs


注:本文中的ITypeSymbol.GetFullName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。