src/Microsoft.VisualStudio.ProjectSystem.Managed/ProjectSystem/SpecialFileProviders/AbstractSpecialFileProvider.cs
/// <summary>
/// We follow this algorithm for looking up files:
///
/// if (not asked to create)
///      Look in AppDesigner folder
///      Look in root folder
///
/// if (asked to create)
///      Look in AppDesigner folder
///      Look in root folder
///      Force-create in app-designer folder unless that file is not created there by default.
///      In that case create under the root node.
/// </summary>
We follow this algorithm for looking up files.

if (not asked to create)
Look in AppDesigner folder
Look in root folder

if (asked to create)
Look in AppDesigner folder
Look in root folder
Force-create in app-designer folder unless that file is not created there by default.
In that case create under the root node.
We follow this algorithm for looking up files . if ( not asked to create ) Look in AppDesigner folder Look in root folder if ( asked to create ) Look in AppDesigner folder Look in root folder Force - create in app - designer folder unless that file is not created there by default . In that case create under the root node .
public async Task<string> GetFileAsync(SpecialFiles fileId, SpecialFileFlags flags, CancellationToken cancellationToken = default(CancellationToken))
        {
            IProjectTree specialFileNode = await FindFileAsync(Name).ConfigureAwait(false);
            if (specialFileNode != null)
            {
                if (await IsNodeInSyncWithDiskAsync(specialFileNode, forceSync: flags.HasFlag(SpecialFileFlags.CreateIfNotExist), cancellationToken: cancellationToken).ConfigureAwait(false))
                {
                    return specialFileNode.FilePath;
                }
            }
            if (flags.HasFlag(SpecialFileFlags.CreateIfNotExist))
            {
                string createdFilePath = await CreateFileAsync(fileId, Name).ConfigureAwait(false);
                if (createdFilePath != null)
                {
                    return createdFilePath;
                }
            }
            IProjectTree rootNode = _projectTree.CurrentTree;
            string rootFilePath = _projectTree.TreeProvider.GetPath(rootNode);
            string fullPath = Path.Combine(Path.GetDirectoryName(rootFilePath), Name);
            return fullPath;
        }
public async Task < string > GetFileAsync ( SpecialFiles fileId , SpecialFileFlags flags , CancellationToken cancellationToken = default ( CancellationToken ) ) { IProjectTree specialFileNode = await FindFileAsync ( Name ) . ConfigureAwait ( false ) ; if ( specialFileNode != null ) { if ( await IsNodeInSyncWithDiskAsync ( specialFileNode , forceSync : flags . HasFlag ( SpecialFileFlags . CreateIfNotExist ) , cancellationToken : cancellationToken ) . ConfigureAwait ( false ) ) { return specialFileNode . FilePath ; } } if ( flags . HasFlag ( SpecialFileFlags . CreateIfNotExist ) ) { string createdFilePath = await CreateFileAsync ( fileId , Name ) . ConfigureAwait ( false ) ; if ( createdFilePath != null ) { return createdFilePath ; } } IProjectTree rootNode = _projectTree . CurrentTree ; string rootFilePath = _projectTree . TreeProvider . GetPath ( rootNode ) ; string fullPath = Path . Combine ( Path . GetDirectoryName ( rootFilePath ) , Name ) ; return fullPath ; }
We follow this algorithm for looking up files:
We follow this algorithm for looking up files :
// Search for the file in the app designer and root folders. // File doesn't exist. Create it if we've been asked to. // We haven't found the file but return the default file path as that's the contract.
fileId
SpecialFiles
flags
SpecialFileFlags
cancellationToken
CancellationToken