private static void ProcessOptions(IProjectChangeDescription projectChange, IWorkspaceProjectContext context)
        {
            // We don't pass differences to Roslyn for options, we just pass them all
            IEnumerable <string> commandlineArguments = projectChange.After.Items.Keys;

            context.SetOptions(string.Join(" ", commandlineArguments));
        }
Beispiel #2
0
        private void ProcessOptions(IProjectRuleSnapshot snapshot)
        {
            // We just pass all options to Roslyn
            string commandlineArguments = string.Join(" ", snapshot.Items.Keys);

            _context.SetOptions(commandlineArguments);
        }
        private static void ProcessOptions(IProjectChangeDescription projectChange, IWorkspaceProjectContext context, IProjectLogger logger)
        {
            // We don't pass differences to Roslyn for options, we just pass them all
            string commandlineArguments = string.Join(" ", projectChange.After.Items.Keys);

            WriteCommandLineArguments(logger, commandlineArguments);
            context.SetOptions(commandlineArguments);
        }
        private async Task <IWorkspaceProjectContext?> CreateProjectContextHandlingFaultAsync(ProjectContextInitData data, object?hostObject)
        {
            try
            {
                // Call into Roslyn to init language service for this project
                IWorkspaceProjectContext context = await _workspaceProjectContextFactory.Value.CreateProjectContextAsync(
                    data.LanguageName,
                    data.WorkspaceProjectContextId,
                    data.ProjectFilePath,
                    data.ProjectGuid,
                    hostObject,
                    data.BinOutputPath,
                    data.AssemblyName,
                    CancellationToken.None);

                context.StartBatch();

                try
                {
                    // Update additional properties within a batch to avoid thread pool starvation.
                    // https://github.com/dotnet/project-system/issues/8027

                    context.LastDesignTimeBuildSucceeded = false;  // By default, turn off diagnostics until the first design time build succeeds for this project.

                    // Pass along any early approximation we have of the command line options
#pragma warning disable CS0618 // This was obsoleted in favor of the one that takes an array, but here just the string is easier; we'll un-Obsolete this API
                    context.SetOptions(data.CommandLineArgsForDesignTimeEvaluation);
#pragma warning restore CS0618 // Type or member is obsolete
                }
                finally
                {
                    await context.EndBatchAsync();
                }

                return(context);
            }
            catch (Exception ex)
            {
                await _faultHandlerService.ReportFaultAsync(ex, _project, ProjectFaultSeverity.LimitedFunctionality);
            }

            return(null);
        }