src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/Editor/ProjectFileEditorPresenter.cs
/// <summary>
/// Causes the dirty changes to the editor to be saved to the disk. This is called by the <seealso cref="ITextBufferStateListener"/>
/// when it detects the user has saved the temp buffer.
/// </summary>
Causes the dirty changes to the editor to be saved to the disk. This is called by the
when it detects the user has saved the temp buffer.
Causes the dirty changes to the editor to be saved to the disk . This is called by the when it detects the user has saved the temp buffer .
public async Task SaveProjectFileAsync()
        {
            lock (_lock)
            {
                if (_currentState == EditorState.NoEditor)
                {
                    throw new InvalidOperationException("In SaveProjectFileAsync with no editor open! Bug!");
                }
                if (_currentState != EditorState.EditorOpen)
                {
                    return;
                }
                _currentState = EditorState.WritingProjectFile;
            }
            try
            {
                await _textBufferManager.SetReadOnlyAsync(true).ConfigureAwait(false);
                await _textBufferManager.SaveAsync().ConfigureAwait(false);
            }
            finally
            {
                await _textBufferManager.SetReadOnlyAsync(false).ConfigureAwait(false);
            }
            lock (_lock)
            {
                _currentState = EditorState.EditorOpen;
            }
        }
public async Task SaveProjectFileAsync ( ) { lock ( _lock ) { if ( _currentState == EditorState . NoEditor ) { throw new InvalidOperationException ( " " ) ; } if ( _currentState != EditorState . EditorOpen ) { return ; } _currentState = EditorState . WritingProjectFile ; } try { await _textBufferManager . SetReadOnlyAsync ( true ) . ConfigureAwait ( false ) ; await _textBufferManager . SaveAsync ( ) . ConfigureAwait ( false ) ; } finally { await _textBufferManager . SetReadOnlyAsync ( false ) . ConfigureAwait ( false ) ; } lock ( _lock ) { _currentState = EditorState . EditorOpen ; } }
Causes the dirty changes to the editor to be saved to the disk.
Causes the dirty changes to the editor to be saved to the disk .
// If we're here and the editor is not open, there's a bug. Normally we'd use the assumes, // but because of https://github.com/dotnet/roslyn-project-system/issues/1077 we can't // and unit test the scenario. So we're throwing an InvalidOperationException instead. // Assumes.True(_currentState != EditorState.NoEditor); // In order to save, the editor must not be in the process of being updated. // While saving the file, we disallow edits to the project file for sync purposes. We also make sure // that the buffer cannot get stuck in a read-only state if SaveAsync fails for some reason.