internal MetadataShadowCopy(ShadowCopy primaryModule, ShadowCopy documentationFileOpt, Metadata metadataCopy) { Debug.Assert(primaryModule != null); Debug.Assert(metadataCopy != null); ////Debug.Assert(!metadataCopy.IsImageOwner); property is now internal PrimaryModule = primaryModule; DocumentationFile = documentationFileOpt; Metadata = metadataCopy; }
internal MetadataShadowCopy(ShadowCopy primaryModule, ShadowCopy documentationFile, Metadata metadataCopy) { Debug.Assert(primaryModule != null); Debug.Assert(metadataCopy != null); ////Debug.Assert(!metadataCopy.IsImageOwner); property is now internal PrimaryModule = primaryModule; DocumentationFile = documentationFile; Metadata = metadataCopy; }
private CacheEntry <MetadataShadowCopy> CreateMetadataShadowCopy(string originalPath, MetadataImageKind kind) { int attempts = 10; while (true) { try { if (ShadowCopyDirectory == null) { ShadowCopyDirectory = CreateUniqueDirectory(_baseDirectory); } // Create directory for the assembly. // If the assembly has any modules they have to be copied to the same directory // and have the same names as specified in metadata. string assemblyCopyDir = CreateUniqueDirectory(ShadowCopyDirectory); string shadowCopyPath = Path.Combine(assemblyCopyDir, Path.GetFileName(originalPath)); ShadowCopy documentationFileCopy = TryCopyDocumentationFile(originalPath, assemblyCopyDir, _documentationCommentsCulture); var manifestModuleCopyStream = CopyFile(originalPath, shadowCopyPath); var manifestModuleCopy = new ShadowCopy(manifestModuleCopyStream, originalPath, shadowCopyPath); Metadata privateMetadata; if (kind == MetadataImageKind.Assembly) { privateMetadata = CreateAssemblyMetadata(manifestModuleCopyStream, originalPath, shadowCopyPath); } else { privateMetadata = CreateModuleMetadata(manifestModuleCopyStream); } var publicMetadata = privateMetadata.Copy(); return(new CacheEntry <MetadataShadowCopy>(new MetadataShadowCopy(manifestModuleCopy, documentationFileCopy, publicMetadata), privateMetadata)); } catch (DirectoryNotFoundException) { // the shadow copy directory has been deleted - try to copy all files again if (!Directory.Exists(ShadowCopyDirectory)) { ShadowCopyDirectory = null; if (attempts-- > 0) { continue; } } throw; } } }
private CacheEntry <MetadataShadowCopy> CreateMetadataShadowCopy(string originalPath, MetadataImageKind kind) { int attempts = 10; while (true) { try { if (ShadowCopyDirectory == null) { ShadowCopyDirectory = CreateUniqueDirectory(_baseDirectory); } // Create directory for the assembly. // If the assembly has any modules they have to be copied to the same directory // and have the same names as specified in metadata. string assemblyDir = CreateUniqueDirectory(ShadowCopyDirectory); string shadowCopyPath = Path.Combine(assemblyDir, Path.GetFileName(originalPath)); ShadowCopy documentationFileCopy = null; string xmlOriginalPath; if (ReferencePathUtilities.TryFindXmlDocumentationFile(originalPath, out xmlOriginalPath)) { // TODO (tomat): how do doc comments work for multi-module assembly? var xmlCopyPath = Path.ChangeExtension(shadowCopyPath, ".xml"); var xmlStream = CopyFile(xmlOriginalPath, xmlCopyPath, fileMayNotExist: true); if (xmlStream != null) { documentationFileCopy = new ShadowCopy(xmlStream, xmlOriginalPath, xmlCopyPath); } } var manifestModuleCopyStream = CopyFile(originalPath, shadowCopyPath); var manifestModuleCopy = new ShadowCopy(manifestModuleCopyStream, originalPath, shadowCopyPath); Metadata privateMetadata; if (kind == MetadataImageKind.Assembly) { privateMetadata = CreateAssemblyMetadata(manifestModuleCopyStream, originalPath, shadowCopyPath); } else { privateMetadata = CreateModuleMetadata(manifestModuleCopyStream); } var publicMetadata = privateMetadata.Copy(); return(new CacheEntry <MetadataShadowCopy>(new MetadataShadowCopy(manifestModuleCopy, documentationFileCopy, publicMetadata), privateMetadata)); } catch (DirectoryNotFoundException) { // the shadow copy directory has been deleted - try to copy all files again if (!Directory.Exists(ShadowCopyDirectory)) { ShadowCopyDirectory = null; if (attempts-- > 0) { continue; } } throw; } } }