internal bool Complete(StrongNameKeys strongNameKeys, CommonMessageProvider messageProvider, DiagnosticBag diagnostics) { RoslynDebug.Assert(_stream != null); RoslynDebug.Assert(_emitStreamSignKind != EmitStreamSignKind.SignedWithFile || _tempInfo.HasValue); try { if (_tempInfo.HasValue) { RoslynDebug.Assert(_emitStreamSignKind == EmitStreamSignKind.SignedWithFile); RoslynDebug.Assert(_strongNameProvider is object); var(tempStream, tempFilePath) = _tempInfo.GetValueOrDefault(); try { // Dispose the temp stream to ensure all of the contents are written to // disk. tempStream.Dispose(); _strongNameProvider.SignFile(strongNameKeys, tempFilePath); using (var tempFileStream = new FileStream(tempFilePath, FileMode.Open)) { tempFileStream.CopyTo(_stream); } } catch (DesktopStrongNameProvider.ClrStrongNameMissingException) { diagnostics.Add(StrongNameKeys.GetError(strongNameKeys.KeyFilePath, strongNameKeys.KeyContainer, new CodeAnalysisResourcesLocalizableErrorArgument(nameof(CodeAnalysisResources.AssemblySigningNotSupported)), messageProvider)); return(false); } catch (IOException ex) { diagnostics.Add(StrongNameKeys.GetError(strongNameKeys.KeyFilePath, strongNameKeys.KeyContainer, ex.Message, messageProvider)); return(false); } } } finally { Close(); } return(true); }