コード例 #1
0
        protected override async Task <Solution> ProcessImpl(Task <string> previousTask)
        {
            var slnObject = await previousTask;

            Contract.Assert(slnObject is string fileName && !string.IsNullOrEmpty(fileName),
                            "Expected previous task to return a " +
                            $"solution filename. Instead returned {slnObject}");
            var slnName = slnObject;

            Contract.Assert(File.Exists(slnName), $"Expected to find {slnName} on the file system, but couldn't.");

            // Log any solution loading issues
            _workspace.WorkspaceFailed += (sender, args) =>
            {
                var message  = $"Issue during solution loading: {sender}: {args.Diagnostic.Message}";
                var logLevel = args.Diagnostic.Kind == WorkspaceDiagnosticKind.Failure ? LogLevel.Error : LogLevel.Warning;

                Logger.Log(logLevel, message);
            };

            // Roslyn does not support FSharp projects, but .fsproj has same structure as .csproj files,
            // so can treat them as a known project type to support diff tracking
            _workspace.AssociateFileExtensionWithLanguage("fsproj", LanguageNames.CSharp);

            return(await _workspace.OpenSolutionAsync(slnName, _progress, CancellationToken));
        }