本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.Symbols.NamespaceSymbol类的典型用法代码示例。如果您正苦于以下问题:C# NamespaceSymbol类的具体用法?C# NamespaceSymbol怎么用?C# NamespaceSymbol使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NamespaceSymbol类属于Microsoft.CodeAnalysis.CSharp.Symbols命名空间,在下文中一共展示了NamespaceSymbol类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: GetExternAliasTarget
internal bool GetExternAliasTarget(string aliasName, out NamespaceSymbol @namespace)
{
if (externAliasTargets == null)
{
Interlocked.CompareExchange(ref this.externAliasTargets, new ConcurrentDictionary<string, NamespaceSymbol>(), null);
}
else if (externAliasTargets.TryGetValue(aliasName, out @namespace))
{
return !(@namespace is MissingNamespaceSymbol);
}
ArrayBuilder<NamespaceSymbol> builder = null;
foreach (var referencedAssembly in GetBoundReferenceManager().ReferencedAssembliesMap.Values)
{
if (referencedAssembly.Aliases.Contains(aliasName))
{
builder = builder ?? ArrayBuilder<NamespaceSymbol>.GetInstance();
builder.Add(referencedAssembly.Symbol.GlobalNamespace);
}
}
bool foundNamespace = builder != null;
// We want to cache failures as well as successes so that subsequent incorrect extern aliases with the
// same alias will have the same target.
@namespace = foundNamespace
? MergedNamespaceSymbol.Create(new NamespaceExtent(this), namespacesToMerge: builder.ToImmutableAndFree(), containingNamespace: null, nameOpt: null)
: new MissingNamespaceSymbol(new MissingModuleSymbol(new MissingAssemblySymbol(new AssemblyIdentity(System.Guid.NewGuid().ToString())), ordinal: -1));
// Use GetOrAdd in case another thread beat us to the punch (i.e. should return the same object for the same alias, every time).
@namespace = externAliasTargets.GetOrAdd(aliasName, @namespace);
Debug.Assert(foundNamespace == !(@namespace is MissingNamespaceSymbol));
return foundNamespace;
}
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:36,代码来源:CSharpCompilation.cs
示例17: Get_System_Runtime_CompilerServices_NamespaceSymbol
internal NamespaceSymbol Get_System_Runtime_CompilerServices_NamespaceSymbol(NamespaceSymbol systemNamespace)
{
var runtimeNS = systemNamespace.GetMember<NamespaceSymbol>("Runtime");
return runtimeNS.GetMember<NamespaceSymbol>("CompilerServices");
}
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:5,代码来源:WellKnownAttributesTestBase.cs
示例18: VisitNamespace
public virtual void VisitNamespace(NamespaceSymbol symbol)
{
DefaultVisit(symbol);
}
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:4,代码来源:SymbolVisitor.cs
示例19: TryGetAssemblyScope
private Cci.IAssemblyReference TryGetAssemblyScope(NamespaceSymbol @namespace, Emit.PEModuleBuilder moduleBuilder, DiagnosticBag diagnostics)
{
AssemblySymbol containingAssembly = @namespace.ContainingAssembly;
if ((object)containingAssembly != null && (object)containingAssembly != moduleBuilder.CommonCompilation.Assembly)
{
var referenceManager = ((CSharpCompilation)moduleBuilder.CommonCompilation).GetBoundReferenceManager();
for (int i = 0; i < referenceManager.ReferencedAssemblies.Length; i++)
{
if ((object)referenceManager.ReferencedAssemblies[i] == containingAssembly)
{
if (!referenceManager.DeclarationsAccessibleWithoutAlias(i))
{
return moduleBuilder.Translate(containingAssembly, diagnostics);
}
}
}
}
return null;
}
开发者ID:RoryVL,项目名称:roslyn,代码行数:21,代码来源:ImportChain.cs
示例20: CreateBinderChain
private static Binder CreateBinderChain(
CSharpCompilation compilation,
PEModuleSymbol module,
NamespaceSymbol @namespace,
ImmutableArray<ImmutableArray<ImportRecord>> importRecordGroups)
{
var stack = ArrayBuilder<string>.GetInstance();
while ((object)@namespace != null)
{
stack.Push(@namespace.Name);
@namespace = @namespace.ContainingNamespace;
}
Binder binder = new BuckStopsHereBinder(compilation);
var hasImports = !importRecordGroups.IsDefaultOrEmpty;
var numImportStringGroups = hasImports ? importRecordGroups.Length : 0;
var currentStringGroup = numImportStringGroups - 1;
// PERF: We used to call compilation.GetCompilationNamespace on every iteration,
// but that involved walking up to the global namespace, which we have to do
// anyway. Instead, we'll inline the functionality into our own walk of the
// namespace chain.
@namespace = compilation.GlobalNamespace;
while (stack.Count > 0)
{
var namespaceName = stack.Pop();
if (namespaceName.Length > 0)
{
// We're re-getting the namespace, rather than using the one containing
// the current frame method, because we want the merged namespace.
@namespace = @namespace.GetNestedNamespace(namespaceName);
Debug.Assert((object)@namespace != null,
$"We worked backwards from symbols to names, but no symbol exists for name '{namespaceName}'");
}
else
{
Debug.Assert((object)@namespace == (object)compilation.GlobalNamespace);
}
Imports imports = null;
if (hasImports)
{
if (currentStringGroup < 0)
{
Debug.WriteLine($"No import string group for namespace '{@namespace}'");
break;
}
var importsBinder = new InContainerBinder(@namespace, binder);
imports = BuildImports(compilation, module, importRecordGroups[currentStringGroup], importsBinder);
currentStringGroup--;
}
binder = new InContainerBinder(@namespace, binder, imports);
}
stack.Free();
if (currentStringGroup >= 0)
{
// CONSIDER: We could lump these into the outermost namespace. It's probably not worthwhile since
// the usings are already for the wrong method.
Debug.WriteLine($"Found {currentStringGroup + 1} import string groups without corresponding namespaces");
}
return binder;
}
开发者ID:rgani,项目名称:roslyn,代码行数:68,代码来源:CompilationContext.cs
注:本文中的Microsoft.CodeAnalysis.CSharp.Symbols.NamespaceSymbol类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论