本文整理汇总了C#中MetadataReferenceProperties类的典型用法代码示例。如果您正苦于以下问题:C# MetadataReferenceProperties类的具体用法?C# MetadataReferenceProperties怎么用?C# MetadataReferenceProperties使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MetadataReferenceProperties类属于命名空间,在下文中一共展示了MetadataReferenceProperties类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResolveReference
public override ImmutableArray<PortableExecutableReference> ResolveReference(string reference, string baseFilePath, MetadataReferenceProperties properties)
{
Dictionary<string, PortableExecutableReference> map;
if (PathUtilities.IsFilePath(reference))
{
if (_pathResolver != null)
{
reference = _pathResolver.ResolvePath(reference, baseFilePath);
if (reference == null)
{
return ImmutableArray<PortableExecutableReference>.Empty;
}
}
map = _files;
}
else
{
map = _assemblyNames;
}
PortableExecutableReference result;
return map.TryGetValue(reference, out result) ? ImmutableArray.Create(result) : ImmutableArray<PortableExecutableReference>.Empty;
}
示例2: GetMetadata
internal Metadata GetMetadata(string fullPath, MetadataReferenceProperties properties)
{
// Check if we have an entry in the dictionary.
FileKey? fileKey = GetUniqueFileKey(fullPath);
Metadata metadata;
if (fileKey.HasValue && metadataCache.TryGetValue(fileKey.Value, out metadata) && metadata != null)
{
CompilerServerLogger.Log("Using already loaded metadata for assembly reference '{0}'", fileKey);
return metadata;
}
if (properties.Kind == MetadataImageKind.Module)
{
var result = CreateModuleMetadata(fullPath, prefetchEntireImage: true);
//?? never add modules to cache?
return result;
}
else
{
var primaryModule = CreateModuleMetadata(fullPath, prefetchEntireImage: false);
// Get all the modules, and load them. Create an assembly metadata.
var allModules = GetAllModules(primaryModule, Path.GetDirectoryName(fullPath));
Metadata result = AssemblyMetadata.Create(allModules);
result = metadataCache.GetOrAdd(fileKey.Value, result);
return result;
}
}
示例3: GetAddOrUpdate
public MetadataReference GetAddOrUpdate(string path, MetadataReferenceProperties properties)
{
using (_gate.DisposableWait())
{
WeakReference<MetadataReference> weakref;
MetadataReference mref = null;
if (!(_references.TryGetValue(properties, out weakref) && weakref.TryGetTarget(out mref)))
{
// try to base this metadata reference off of an existing one, so we don't load the metadata bytes twice.
foreach (var wr in _references.Values)
{
if (wr.TryGetTarget(out mref))
{
mref = mref.WithProperties(properties);
break;
}
}
if (mref == null)
{
mref = _cache._createReference(path, properties);
}
_references[properties] = new WeakReference<MetadataReference>(mref);
}
return mref;
}
}
示例4: MetadataFileReference
public MetadataFileReference(string fullPath, MetadataReferenceProperties properties, DocumentationProvider documentation = null)
: base(properties, fullPath, initialDocumentation: documentation ?? DocumentationProvider.Default)
{
if (fullPath == null)
{
throw new ArgumentNullException("fullPath");
}
}
示例5: ShadowCopyReference
public ShadowCopyReference(MetadataShadowCopyProvider provider, string originalPath, MetadataReferenceProperties properties)
: base(properties, originalPath)
{
Debug.Assert(originalPath != null);
Debug.Assert(provider != null);
_provider = provider;
}
示例6: GetReference
public MetadataReference GetReference(string path, MetadataReferenceProperties properties)
{
if (!_referenceSets.TryGetValue(path, out var referenceSet))
{
referenceSet = ImmutableInterlocked.GetOrAdd(ref _referenceSets, path, new ReferenceSet(this));
}
return referenceSet.GetAddOrUpdate(path, properties);
}
示例7: WithProperties
/// <summary>
/// Returns an instance of the reference with specified properties, or this instance if properties haven't changed.
/// </summary>
/// <param name="properties">The new properties for the reference.</param>
/// <exception cref="ArgumentException">Specified values not valid for this reference.</exception>
public MetadataReference WithProperties(MetadataReferenceProperties properties)
{
if (properties == this.Properties)
{
return this;
}
return WithPropertiesImplReturningMetadataReference(properties);
}
示例8: PortableExecutableReference
protected PortableExecutableReference(
MetadataReferenceProperties properties,
string fullPath = null,
DocumentationProvider initialDocumentation = null)
: base(properties)
{
_filePath = fullPath;
_lazyDocumentation = initialDocumentation;
}
示例9: WithPropertiesImpl
protected override PortableExecutableReference WithPropertiesImpl(MetadataReferenceProperties properties)
{
return new MetadataImageReference(
_metadata,
properties,
this.DocumentationProvider,
this.FilePath,
_display);
}
示例10: ResolveReference
public override ImmutableArray<PortableExecutableReference> ResolveReference(string reference, string baseFilePath, MetadataReferenceProperties properties)
{
var path = PathResolver.ResolveReference(reference, baseFilePath);
if (path == null)
{
return ImmutableArray<PortableExecutableReference>.Empty;
}
return ImmutableArray.Create(Provider.GetReference(path, properties));
}
示例11: GetReference
public override PortableExecutableReference GetReference(string fullPath, MetadataReferenceProperties properties = default(MetadataReferenceProperties))
{
AssemblyMetadata metadata;
if (_cache.TryGetValue(fullPath, out metadata))
{
return metadata.GetReference(MakeDocumentationProvider());
}
_cache.Add(fullPath, metadata = AssemblyMetadata.CreateFromFile(fullPath));
return metadata.GetReference(MakeDocumentationProvider());
}
示例12: ResolveReference
public override ImmutableArray<PortableExecutableReference> ResolveReference(string reference, string baseFilePath, MetadataReferenceProperties properties)
{
// Note: currently not handling relative paths, since we don't have tests that use them
if (File.Exists(reference))
{
return ImmutableArray.Create(MetadataReference.CreateFromFile(reference, properties));
}
return default(ImmutableArray<PortableExecutableReference>);
}
示例13: AddProjectReference
public void AddProjectReference(IProjectContext project, MetadataReferenceProperties properties)
{
// AbstractProject and ProjectTracker track project references using the project bin output path.
// Setting the command line arguments should have already set the output file name and folder.
// We fetch this output path to add the reference.
var referencedProject = this.ProjectTracker.GetProject(project.Id);
var binPathOpt = referencedProject.TryGetBinOutputPath();
if (!string.IsNullOrEmpty(binPathOpt))
{
AddMetadataReferenceAndTryConvertingToProjectReferenceIfPossible(binPathOpt, properties);
}
}
示例14: WithProperties
/// <summary>
/// Returns an instance of the reference with specified properties, or this instance if properties haven't changed.
/// </summary>
/// <param name="properties">The new properties for the reference.</param>
/// <exception cref="ArgumentException">Specified values not valid for this reference.</exception>
public new CompilationReference WithProperties(MetadataReferenceProperties properties)
{
if (properties == this.Properties)
{
return this;
}
if (properties.Kind == MetadataImageKind.Module)
{
throw new ArgumentException(CodeAnalysisResources.CannotCreateReferenceToModule);
}
return WithPropertiesImpl(properties);
}
示例15: WithXxx
public void WithXxx()
{
var p = new MetadataReferenceProperties(MetadataImageKind.Assembly, ImmutableArray.Create("a"), embedInteropTypes: false);
Assert.Equal(p.WithAliases(null), new MetadataReferenceProperties(MetadataImageKind.Assembly, ImmutableArray<string>.Empty, embedInteropTypes: false));
Assert.Equal(p.WithAliases(default(ImmutableArray<string>)), new MetadataReferenceProperties(MetadataImageKind.Assembly, ImmutableArray<string>.Empty, embedInteropTypes: false));
Assert.Equal(p.WithAliases(ImmutableArray<string>.Empty), new MetadataReferenceProperties(MetadataImageKind.Assembly, default(ImmutableArray<string>), embedInteropTypes: false));
Assert.Equal(p.WithAliases(new string[0]), new MetadataReferenceProperties(MetadataImageKind.Assembly, default(ImmutableArray<string>), embedInteropTypes: false));
Assert.Equal(p.WithAliases(new[] { "foo", "aaa" }), new MetadataReferenceProperties(MetadataImageKind.Assembly, ImmutableArray.Create("foo", "aaa"), embedInteropTypes: false));
Assert.Equal(p.WithEmbedInteropTypes(true), new MetadataReferenceProperties(MetadataImageKind.Assembly, ImmutableArray.Create("a"), embedInteropTypes: true));
var m = new MetadataReferenceProperties(MetadataImageKind.Module);
Assert.Equal(m.WithAliases(default(ImmutableArray<string>)), new MetadataReferenceProperties(MetadataImageKind.Module, default(ImmutableArray<string>), embedInteropTypes: false));
Assert.Equal(m.WithEmbedInteropTypes(false), new MetadataReferenceProperties(MetadataImageKind.Module, default(ImmutableArray<string>), embedInteropTypes: false));
}