本文整理汇总了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();
}
示例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);
}
}
示例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.");
}
}
示例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);
}
示例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);
}
示例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;
}