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


C# Symbols.NamespaceSymbol类代码示例

本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.Symbols.NamespaceSymbol的典型用法代码示例。如果您正苦于以下问题:C# NamespaceSymbol类的具体用法?C# NamespaceSymbol怎么用?C# NamespaceSymbol使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


NamespaceSymbol类属于Microsoft.CodeAnalysis.CSharp.Symbols命名空间,在下文中一共展示了NamespaceSymbol类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LoadChildNamespace2

        private XElement LoadChildNamespace2(NamespaceSymbol n)
        {
            XElement elem = new XElement((n.Name.Length == 0 ? "Global" : n.Name));

            var children = n.GetMembers();
            n = null;

            var types = new List<NamedTypeSymbol>();
            var namespaces = new List<NamespaceSymbol>();

            foreach (var c in children)
            {
                NamedTypeSymbol t = c as NamedTypeSymbol;

                if (t != null)
                {
                    types.Add(t);
                }
                else
                {
                    namespaces.Add(((NamespaceSymbol)c));
                }
            }

            var childrenTypes = types.OrderBy(t => t, new NameAndArityComparer());

            elem.Add(from t in childrenTypes select LoadChildType(t));

            var childrenNS = namespaces.OrderBy((child) => child.Name, StringComparer.OrdinalIgnoreCase);

            elem.Add(from c in childrenNS select LoadChildNamespace2(c));

            return elem;
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:34,代码来源:LoadingNamespacesAndTypes.cs

示例2: TypeDocumentationCommentTests

        public TypeDocumentationCommentTests()
        {
            _compilation = CreateCompilationWithMscorlibAndDocumentationComments(@"enum Color { Red, Blue, Green }
namespace Acme
{
	interface IProcess {...}
	struct ValueType {...}
	class Widget: IProcess
	{
        /// <summary>
        /// Hello! Nested Class.
        /// </summary>
		public class NestedClass {...}
		public interface IMenuItem {...}
		public delegate void Del(int i);
		public enum Direction { North, South, East, West }
	}
	class MyList<T>
	{
		class Helper<U,V> {...}
	}
}");

            _acmeNamespace = (NamespaceSymbol)_compilation.GlobalNamespace.GetMembers("Acme").Single();
            _widgetClass = _acmeNamespace.GetTypeMembers("Widget").Single();
        }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:26,代码来源:TypeDocumentationCommentTests.cs

示例3: MissingNamespaceSymbol

        public MissingNamespaceSymbol(NamespaceSymbol containingNamespace, string name)
        {
            Debug.Assert((object)containingNamespace != null);
            Debug.Assert(name != null);

            _containingSymbol = containingNamespace;
            _name = name;
        }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:8,代码来源:MissingNamespaceSymbol.cs

示例4: VisitNamespace

        public override void VisitNamespace(NamespaceSymbol symbol)
        {
            _cancellationToken.ThrowIfCancellationRequested();

            foreach (var s in symbol.GetMembers())
            {
                s.Accept(this);
            }
        }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:9,代码来源:SynthesizedMetadataCompiler.cs

示例5: RetargetingNamespaceSymbol

        public RetargetingNamespaceSymbol(RetargetingModuleSymbol retargetingModule, NamespaceSymbol underlyingNamespace)
        {
            Debug.Assert((object)retargetingModule != null);
            Debug.Assert((object)underlyingNamespace != null);
            Debug.Assert(!(underlyingNamespace is RetargetingNamespaceSymbol));

            this.retargetingModule = retargetingModule;
            this.underlyingNamespace = underlyingNamespace;
        }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:9,代码来源:RetargetingNamespaceSymbol.cs

示例6: EENamedTypeSymbol

 internal EENamedTypeSymbol(
     NamespaceSymbol container,
     NamedTypeSymbol baseType,
     CSharpSyntaxNode syntax,
     MethodSymbol currentFrame,
     string typeName,
     string methodName,
     CompilationContext context,
     GenerateMethodBody generateMethodBody) :
     this(container, baseType, syntax, currentFrame, typeName, (m, t) => ImmutableArray.Create<MethodSymbol>(context.CreateMethod(t, methodName, syntax, generateMethodBody)))
 {
 }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:12,代码来源:EENamedTypeSymbol.cs

示例7: DestructorDocumentationCommentTests

        public DestructorDocumentationCommentTests()
        {
            _compilation = CreateCompilationWithMscorlibAndDocumentationComments(@"namespace Acme
{
	class Widget: IProcess
	{
        /// <summary>Destructor Documentation</summary>
        ~Widget() {...}
	}
}
");

            _acmeNamespace = (NamespaceSymbol)_compilation.GlobalNamespace.GetMembers("Acme").Single();
            _widgetClass = _acmeNamespace.GetTypeMembers("Widget").Single();
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:15,代码来源:DestructorDocumentationCommentTests.cs

示例8: EventDocumentationCommentTests

        public EventDocumentationCommentTests()
        {
            compilation = CreateCompilationWithMscorlib(@"namespace Acme
{
    class Widget: IProcess
    {
        public event System.Action E;
        public event System.Action F { add { } remove { } }
    }
}
");

            acmeNamespace = (NamespaceSymbol)compilation.GlobalNamespace.GetMember<NamespaceSymbol>("Acme");
            widgetClass = acmeNamespace.GetMember<NamedTypeSymbol>("Widget");
        }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:15,代码来源:EventDocumentationCommentTests.cs

示例9: PropertyDocumentationCommentTests

        public PropertyDocumentationCommentTests()
        {
            compilation = CreateCompilationWithMscorlib(@"namespace Acme
{
    class Widget: IProcess
    {
        public int Width { get { } set { } }
        public int this[int i] { get { } set { } }
        public int this[string s, int i] { get { } set { } }
    }
}
");

            acmeNamespace = (NamespaceSymbol)compilation.GlobalNamespace.GetMembers("Acme").Single();
            widgetClass = acmeNamespace.GetTypeMembers("Widget").Single();
        }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:16,代码来源:PropertyDocumentationCommentTests.cs

示例10: MergedNamespaceSymbol

        // Constructor. Use static Create method to create instances.
        private MergedNamespaceSymbol(NamespaceExtent extent, NamespaceSymbol containingNamespace, ImmutableArray<NamespaceSymbol> namespacesToMerge, string nameOpt)
        {
            this.extent = extent;
            this.namespacesToMerge = namespacesToMerge;
            this.containingNamespace = containingNamespace;
            this.cachedLookup = new CachingDictionary<string, Symbol>(SlowGetChildrenOfName, SlowGetChildNames, EqualityComparer<string>.Default);
            this.nameOpt = nameOpt;

#if DEBUG
            // We shouldn't merged namespaces that are already merged.
            foreach (NamespaceSymbol ns in namespacesToMerge)
            {
                Debug.Assert(ns.ConstituentNamespaces.Length == 1);
            }
#endif
        }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:17,代码来源:MergedNamespaceSymbol.cs

示例11: LoadChildNamespace

        internal static XElement LoadChildNamespace(NamespaceSymbol n)
        {
            XElement elem = new XElement((n.Name.Length == 0 ? "Global" : n.Name));

            var childrenTypes = n.GetTypeMembers().OrderBy((t) => t, new NameAndArityComparer());

            elem.Add(from t in childrenTypes select LoadChildType(t));

            var childrenNS = n.GetMembers().
                                OfType<NamespaceSymbol>().
                                OrderBy(child => child.Name, StringComparer.OrdinalIgnoreCase);

            elem.Add(from c in childrenNS select LoadChildNamespace(c));

            return elem;
        }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:16,代码来源:EmitMetadataTestBase.cs

示例12: MethodDocumentationCommentTests

        public MethodDocumentationCommentTests()
        {
            _compilation = CreateCompilationWithMscorlibAndDocumentationComments(@"namespace Acme
{
    struct ValueType
    {
        public void M(int i) { }

        public static explicit operator ValueType (byte value)
        {
            return default(ValueType);
        }
    }
    class Widget: IProcess
    {
        public class NestedClass
        {
            public void M(int i) { }
        }

        /// <summary>M0 Summary.</summary>
        public static void M0() { }
        public void M1(char c, out float f, ref ValueType v) { }
        public void M2(short[] x1, int[,] x2, long[][] x3) { }
        public void M3(long[][] x3, Widget[][,,] x4) { }
        public unsafe void M4(char *pc, Color **pf) { }
        public unsafe void M5(void *pv, double *[][,] pd) { }
        public void M6(int i, params object[] args) { }
    }
    class MyList<T>
    {
        public void Test(T t) { }
        public void Zip(MyList<T> other) { }
        public void ReallyZip(MyList<MyList<T>> other) { }
    }
    class UseList
    {
        public void Process(MyList<int> list) { }
        public MyList<T> GetValues<T>(T inputValue) { return null; }
    }
}
");

            _acmeNamespace = (NamespaceSymbol)_compilation.GlobalNamespace.GetMembers("Acme").Single();
            _widgetClass = _acmeNamespace.GetTypeMembers("Widget").Single();
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:46,代码来源:MethodDocumentationCommentTests.cs

示例13: FieldDocumentationCommentTests

        public FieldDocumentationCommentTests()
        {
            _compilation = CreateCompilationWithMscorlibAndDocumentationComments(@"
namespace Acme
{
	struct ValueType
	{
        /// <summary>Summary for total fields.</summary>
		private int total1, total2;
	}
	class Widget: IProcess
	{
		public class NestedClass
		{
			private int value;
		}
		private string message;
		private static Color defaultColor;
		private const double PI = 3.14159;
		protected readonly double monthlyAverage;
		private long[] array1;
		private Widget[,] array2;
		private unsafe int *pCount;
		private unsafe float **ppValues;
	}

    enum E
    {
        /// <summary>Enum field</summary>
        A = 1
    }
}
");

            _acmeNamespace = (NamespaceSymbol)_compilation.GlobalNamespace.GetMembers("Acme").Single();
            _widgetClass = _acmeNamespace.GetTypeMembers("Widget").Single();
            _enumSymbol = _acmeNamespace.GetTypeMembers("E").Single();
            _valueType = _acmeNamespace.GetTypeMembers("ValueType").Single();
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:39,代码来源:FieldDocumentationCommentTests.cs

示例14: ConstructorDocumentationCommentTests

        public ConstructorDocumentationCommentTests()
        {
            compilation = CreateCompilationWithMscorlibAndDocumentationComments(@"namespace Acme
{
	class Widget: IProcess
	{
        /// <summary>Static Constructor</summary>
        static Widget() {...}
        /** <summary>Instance Constructor</summary> */
        public Widget() {...}
        /// <summary>
        /// Parameterized Constructor
        /// </summary>
        /// <param name=""s"">s, the string argument</param>
        public Widget(string s) {...}
	}
}
");

            acmeNamespace = (NamespaceSymbol)compilation.GlobalNamespace.GetMembers("Acme").Single();
            widgetClass = acmeNamespace.GetTypeMembers("Widget").Single();
        }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:22,代码来源:ConstructorDocumentationCommentTests.cs

示例15: Create

        /// <summary>
        /// Create a possibly merged namespace symbol. If only a single namespace is passed it, it
        /// is just returned directly. If two or more namespaces are passed in, then a new merged
        /// namespace is created with the given extent and container.
        /// </summary>
        /// <param name="extent">The namespace extent to use, IF a merged namespace is created.</param>
        /// <param name="containingNamespace">The containing namespace to used, IF a merged
        /// namespace is created.</param>
        /// <param name="namespacesToMerge">One or more namespaces to merged. If just one, then it
        /// is returned. The merged namespace symbol may hold onto the array.</param>
        /// <param name="nameOpt">An optional name to give the resulting namespace.</param>
        /// <returns>A namespace symbol representing the merged namespace.</returns>
        internal static NamespaceSymbol Create(
            NamespaceExtent extent,
            NamespaceSymbol containingNamespace,
            ImmutableArray<NamespaceSymbol> namespacesToMerge,
            string nameOpt = null)
        {
            // Currently, if we are just merging 1 namespace, we just return the namespace itself.
            // This is by far the most efficient, because it means that we don't create merged
            // namespaces (which have a fair amount of memory overhead) unless there is actual
            // merging going on. However, it means that the child namespace of a Compilation extent
            // namespace may be a Module extent namespace, and the containing of that module extent
            // namespace will be another module extent namespace. This is basically no different
            // than type members of namespaces, so it shouldn't be TOO unexpected.

            // EDMAURER if the caller is supplying a name, then produce the merged namespace with
            // the new name even if only a single namespace was provided. This behavior was introduced
            // to support nice extern alias error reporting.

            Debug.Assert(namespacesToMerge.Length != 0);

            return (namespacesToMerge.Length == 1 && nameOpt == null)
                ? namespacesToMerge[0]
                : new MergedNamespaceSymbol(extent, containingNamespace, namespacesToMerge, nameOpt);
        }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:36,代码来源:MergedNamespaceSymbol.cs


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