private void Initialize(IEnumerable <string> usings, bool allowUnsafe, IEnumerable <string> features, string runtimeMetadataVersion) { this.Usings = usings.AsImmutableOrEmpty(); this.AllowUnsafe = allowUnsafe; this.Features = features.AsImmutableOrEmpty(); this.RuntimeMetadataVersion = runtimeMetadataVersion; }
internal CSharpCompilationOptions WithFeatures(IEnumerable <string> features) { return(new CSharpCompilationOptions(this) { Features = features.AsImmutableOrEmpty() }); }
// Expects correct arguments. internal CSharpCompilationOptions( OutputKind outputKind, string moduleName, string mainTypeName, string scriptClassName, IEnumerable <string> usings, OptimizationLevel optimizationLevel, bool checkOverflow, bool allowUnsafe, string cryptoKeyContainer, string cryptoKeyFile, ImmutableArray <byte> cryptoPublicKey, bool?delaySign, Platform platform, ReportDiagnostic generalDiagnosticOption, int warningLevel, IEnumerable <KeyValuePair <string, ReportDiagnostic> > specificDiagnosticOptions, bool concurrentBuild, bool extendedCustomDebugInformation, XmlReferenceResolver xmlReferenceResolver, SourceReferenceResolver sourceReferenceResolver, MetadataReferenceResolver metadataReferenceResolver, AssemblyIdentityComparer assemblyIdentityComparer, StrongNameProvider strongNameProvider, MetadataImportOptions metadataImportOptions) : base(outputKind, moduleName, mainTypeName, scriptClassName, cryptoKeyContainer, cryptoKeyFile, cryptoPublicKey, delaySign, optimizationLevel, checkOverflow, platform, generalDiagnosticOption, warningLevel, specificDiagnosticOptions.ToImmutableDictionaryOrEmpty(), concurrentBuild, extendedCustomDebugInformation, xmlReferenceResolver, sourceReferenceResolver, metadataReferenceResolver, assemblyIdentityComparer, strongNameProvider, metadataImportOptions) { this.Usings = usings.AsImmutableOrEmpty(); this.AllowUnsafe = allowUnsafe; }
public CSharpCompilationOptions WithUsings(IEnumerable <string> usings) { return(new CSharpCompilationOptions(this) { Usings = usings.AsImmutableOrEmpty() }); }
public CompletionPresenter( ICompletionBroker completionBroker, IGlyphService glyphService, [ImportMany] IEnumerable <Lazy <ICompletionSetFactory, VisualStudioVersionMetadata> > completionSetFactories) { _completionBroker = completionBroker; _glyphService = glyphService; _completionSetFactories = completionSetFactories.AsImmutableOrEmpty(); }
// TODO: remove the AllowDefault = true on HostDiagnosticUpdateSource by making it a proper mock public VisualStudioProjectFactory( VisualStudioWorkspaceImpl visualStudioWorkspaceImpl, [ImportMany] IEnumerable <Lazy <IDynamicFileInfoProvider, FileExtensionsMetadata> > fileInfoProviders, [Import(AllowDefault = true)] HostDiagnosticUpdateSource hostDiagnosticUpdateSource) { _visualStudioWorkspaceImpl = visualStudioWorkspaceImpl; _dynamicFileInfoProviders = fileInfoProviders.AsImmutableOrEmpty(); _hostDiagnosticUpdateSource = hostDiagnosticUpdateSource; }
/// <summary> /// Creates a top level code action with multiple code action choices a user can invoke. /// </summary> public static CodeAction Create(string title, IEnumerable <CodeAction> nestedActions, string equivalenceKey = null) { if (title == null) { throw new ArgumentNullException(nameof(title)); } return(new SimpleCodeAction(title, nestedActions.AsImmutableOrEmpty(), equivalenceKey)); }
/// <summary> /// Creates a new instance of <see cref="CSharpGeneratorDriver"/> with the specified <see cref="ISourceGenerator"/>s and the provided options or default. /// </summary> /// <param name="generators">The generators to create this driver with</param> /// <param name="additionalTexts">A list of <see cref="AdditionalText"/>s available to generators in this driver, or <c>null</c> if there are none.</param> /// <param name="parseOptions">The <see cref="CSharpParseOptions"/> that should be used when parsing generated files, or <c>null</c> to use <see cref="CSharpParseOptions.Default"/></param> /// <param name="optionsProvider">An <see cref="AnalyzerConfigOptionsProvider"/> that can be used to retrieve analyzer config values by the generators in this driver, or <c>null</c> if there are none.</param> /// <returns>A new <see cref="CSharpGeneratorDriver"/> instance.</returns> public static CSharpGeneratorDriver Create( IEnumerable <ISourceGenerator> generators, IEnumerable <AdditionalText>?additionalTexts = null, CSharpParseOptions?parseOptions = null, AnalyzerConfigOptionsProvider?optionsProvider = null ) => new CSharpGeneratorDriver( parseOptions ?? CSharpParseOptions.Default, generators.ToImmutableArray(), optionsProvider ?? CompilerAnalyzerConfigOptionsProvider.Empty, additionalTexts.AsImmutableOrEmpty() );
private void RaiseDiagnosticsCreatedForProject(ProjectId projectId, object key, IEnumerable<DiagnosticData> items) { var args = DiagnosticsUpdatedArgs.DiagnosticsCreated( CreateId(projectId, key), _workspace, solution: null, projectId: projectId, documentId: null, diagnostics: items.AsImmutableOrEmpty()); RaiseDiagnosticsUpdated(args); }
private void RaiseDiagnosticsUpdatedForProject(ProjectId projectId, object key, IEnumerable<DiagnosticData> items) { var args = new DiagnosticsUpdatedArgs( id: Tuple.Create(this, projectId, key), workspace: _workspace, solution: null, projectId: projectId, documentId: null, diagnostics: items.AsImmutableOrEmpty()); RaiseDiagnosticsUpdated(args); }
private void RaiseDiagnosticsUpdatedForProject(ProjectId projectId, object key, IEnumerable <DiagnosticData> items) { var args = new DiagnosticsUpdatedArgs( id: Tuple.Create(this, projectId, key), workspace: _workspace, solution: null, projectId: projectId, documentId: null, diagnostics: items.AsImmutableOrEmpty()); RaiseDiagnosticsUpdated(args); }
private void RaiseDiagnosticsCreatedForProject(ProjectId projectId, object key, IEnumerable <DiagnosticData> items) { var args = DiagnosticsUpdatedArgs.DiagnosticsCreated( CreateId(projectId, key), _workspace, solution: null, projectId: projectId, documentId: null, diagnostics: items.AsImmutableOrEmpty()); RaiseDiagnosticsUpdated(args); }
public VisualStudioProjectFactory( IThreadingContext threadingContext, VisualStudioWorkspaceImpl visualStudioWorkspaceImpl, [ImportMany] IEnumerable <Lazy <IDynamicFileInfoProvider, FileExtensionsMetadata> > fileInfoProviders, HostDiagnosticUpdateSource hostDiagnosticUpdateSource, SVsServiceProvider serviceProvider) { _threadingContext = threadingContext; _visualStudioWorkspaceImpl = visualStudioWorkspaceImpl; _dynamicFileInfoProviders = fileInfoProviders.AsImmutableOrEmpty(); _hostDiagnosticUpdateSource = hostDiagnosticUpdateSource; _serviceProvider = (Shell.IAsyncServiceProvider)serviceProvider; }
/// <summary> /// Creates a new <see cref="ScriptOptions"/> with the search paths changed. /// </summary> public ScriptOptions WithSearchPaths(IEnumerable <string> searchPaths) { if (this.SearchPaths.SequenceEqual(searchPaths)) { return(this); } else { // TODO: var resolver = new AssemblyReferenceResolver( _referenceResolver.PathResolver.WithSearchPaths(searchPaths.AsImmutableOrEmpty()), _referenceResolver.Provider); return(With(resolver: resolver)); } }
private RemoteHostClientServiceFactory.RemoteHostClientService CreateRemoteHostClientService( Workspace workspace = null, IEnumerable <AnalyzerReference> hostAnalyzerReferences = null, IAsynchronousOperationListenerProvider listenerProvider = null) { workspace ??= new AdhocWorkspace(TestHostServices.CreateHostServices()); workspace.TryApplyChanges(workspace.CurrentSolution.WithOptions(workspace.Options .WithChangedOption(RemoteHostOptions.RemoteHostTest, true) .WithChangedOption(SolutionCrawlerOptions.BackgroundAnalysisScopeOption, LanguageNames.CSharp, BackgroundAnalysisScope.FullSolution) .WithChangedOption(SolutionCrawlerOptions.BackgroundAnalysisScopeOption, LanguageNames.VisualBasic, BackgroundAnalysisScope.FullSolution))); var analyzerService = new TestDiagnosticAnalyzerService(hostAnalyzerReferences.AsImmutableOrEmpty()); var threadingContext = ((IMefHostExportProvider)workspace.Services.HostServices).GetExports <IThreadingContext>().Single().Value; var factory = new RemoteHostClientServiceFactory(threadingContext, listenerProvider ?? AsynchronousOperationListenerProvider.NullProvider, analyzerService); return(factory.CreateService(workspace.Services) as RemoteHostClientServiceFactory.RemoteHostClientService); }
internal SuggestedAction( Workspace workspace, ITextBuffer subjectBuffer, ICodeActionEditHandlerService editHandler, CodeAction codeAction, object provider, IEnumerable <SuggestedActionSet> actionSets = null) { Contract.ThrowIfTrue(provider == null); this.Workspace = workspace; this.SubjectBuffer = subjectBuffer; this.CodeAction = codeAction; this.EditHandler = editHandler; this.Provider = provider; _actionSets = actionSets.AsImmutableOrEmpty(); }
internal CSharpCompilationOptions( OutputKind outputKind, bool reportSuppressedDiagnostics, string?moduleName, string?mainTypeName, string?scriptClassName, IEnumerable <string>?usings, OptimizationLevel optimizationLevel, bool checkOverflow, bool allowUnsafe, string?cryptoKeyContainer, string?cryptoKeyFile, ImmutableArray <byte> cryptoPublicKey, bool?delaySign, Platform platform, ReportDiagnostic generalDiagnosticOption, int warningLevel, IEnumerable <KeyValuePair <string, ReportDiagnostic> >?specificDiagnosticOptions, bool concurrentBuild, bool deterministic, DateTime currentLocalTime, bool debugPlusMode, XmlReferenceResolver?xmlReferenceResolver, SourceReferenceResolver?sourceReferenceResolver, MetadataReferenceResolver?metadataReferenceResolver, AssemblyIdentityComparer?assemblyIdentityComparer, StrongNameProvider?strongNameProvider, MetadataImportOptions metadataImportOptions, bool referencesSupersedeLowerVersions, bool publicSign, BinderFlags topLevelBinderFlags, NullableContextOptions nullableContextOptions, decimal warningVersion = 0m) : base(outputKind, reportSuppressedDiagnostics, moduleName, mainTypeName, scriptClassName, cryptoKeyContainer, cryptoKeyFile, cryptoPublicKey, delaySign, publicSign, optimizationLevel, checkOverflow, platform, generalDiagnosticOption, warningLevel, specificDiagnosticOptions.ToImmutableDictionaryOrEmpty(), concurrentBuild, deterministic, currentLocalTime, debugPlusMode, xmlReferenceResolver, sourceReferenceResolver, metadataReferenceResolver, assemblyIdentityComparer, strongNameProvider, metadataImportOptions, referencesSupersedeLowerVersions) { this.Usings = usings.AsImmutableOrEmpty(); this.AllowUnsafe = allowUnsafe; this.TopLevelBinderFlags = topLevelBinderFlags; this.NullableContextOptions = nullableContextOptions; this.WarningVersion = warningVersion; }
// Defaults correspond to the compiler's defaults or indicate that the user did not specify when that is significant. // That's significant when one option depends on another's setting. SubsystemVersion depends on Platform and Target. public LanguageCompilationOptions( Language language, OutputKind outputKind, bool reportSuppressedDiagnostics = false, string moduleName = null, string mainTypeName = null, string scriptClassName = null, IEnumerable <string> usings = null, OptimizationLevel optimizationLevel = OptimizationLevel.Debug, bool checkOverflow = false, bool allowUnsafe = false, string cryptoKeyContainer = null, string cryptoKeyFile = null, ImmutableArray <byte> cryptoPublicKey = default(ImmutableArray <byte>), bool?delaySign = null, Platform platform = Platform.AnyCpu, ReportDiagnostic generalDiagnosticOption = ReportDiagnostic.Default, int warningLevel = 4, IEnumerable <KeyValuePair <string, ReportDiagnostic> > specificDiagnosticOptions = null, bool concurrentBuild = true, bool deterministic = false, DateTime currentLocalTime = default(DateTime), bool debugPlusMode = false, XmlReferenceResolver xmlReferenceResolver = null, SourceReferenceResolver sourceReferenceResolver = null, MetadataReferenceResolver metadataReferenceResolver = null, AssemblyIdentityComparer assemblyIdentityComparer = null, StrongNameProvider strongNameProvider = null, bool publicSign = false, MetadataImportOptions metadataImportOptions = MetadataImportOptions.Public, bool referencesSupersedeLowerVersions = false, BinderFlags topLevelBinderFlags = null) : base(outputKind, reportSuppressedDiagnostics, moduleName, mainTypeName, scriptClassName, cryptoKeyContainer, cryptoKeyFile, cryptoPublicKey, delaySign, publicSign, optimizationLevel, checkOverflow, platform, generalDiagnosticOption, warningLevel, specificDiagnosticOptions.ToImmutableDictionaryOrEmpty(), concurrentBuild, deterministic, currentLocalTime, debugPlusMode, xmlReferenceResolver, sourceReferenceResolver, metadataReferenceResolver, assemblyIdentityComparer, strongNameProvider, metadataImportOptions, referencesSupersedeLowerVersions) { _language = language; this.Usings = usings.AsImmutableOrEmpty(); this.AllowUnsafe = allowUnsafe; this.TopLevelBinderFlags = topLevelBinderFlags ?? BinderFlags.None; }
// Expects correct arguments. internal CSharpCompilationOptions( OutputKind outputKind, string moduleName, string mainTypeName, string scriptClassName, IEnumerable <string> usings, bool optimize, bool checkOverflow, bool allowUnsafe, string cryptoKeyContainer, string cryptoKeyFile, bool?delaySign, int fileAlignment, ulong baseAddress, Platform platform, ReportDiagnostic generalDiagnosticOption, int warningLevel, IEnumerable <KeyValuePair <string, ReportDiagnostic> > specificDiagnosticOptions, bool highEntropyVirtualAddressSpace, DebugInformationKind debugInformationKind, SubsystemVersion subsystemVersion, string runtimeMetadataVersion, bool concurrentBuild, XmlReferenceResolver xmlReferenceResolver, SourceReferenceResolver sourceReferenceResolver, MetadataReferenceResolver metadataReferenceResolver, MetadataReferenceProvider metadataReferenceProvider, AssemblyIdentityComparer assemblyIdentityComparer, StrongNameProvider strongNameProvider, MetadataImportOptions metadataImportOptions, ImmutableArray <string> features) : base(outputKind, moduleName, mainTypeName, scriptClassName, cryptoKeyContainer, cryptoKeyFile, delaySign, optimize, checkOverflow, fileAlignment, baseAddress, platform, generalDiagnosticOption, warningLevel, specificDiagnosticOptions, highEntropyVirtualAddressSpace, debugInformationKind, subsystemVersion, concurrentBuild, xmlReferenceResolver, sourceReferenceResolver, metadataReferenceResolver, metadataReferenceProvider, assemblyIdentityComparer, strongNameProvider, metadataImportOptions, features) { this.Usings = usings.AsImmutableOrEmpty(); this.AllowUnsafe = allowUnsafe; this.RuntimeMetadataVersion = runtimeMetadataVersion; }
public ScriptMetadataResolver WithSearchPaths(IEnumerable <string> searchPaths) => WithSearchPaths(searchPaths.AsImmutableOrEmpty());
/// <summary> /// Creates a new <see cref="ScriptOptions"/> with <see cref="SourceResolver"/> set to the default source resolver for the current platform. /// </summary> /// <param name="searchPaths">Directories to be used by the default resolver when resolving script file names.</param> /// <remarks> /// The default resolver looks up scripts in specified <paramref name="searchPaths"/> and in NuGet packages. /// </remarks> public ScriptOptions WithDefaultSourceResolution(IEnumerable <string> searchPaths) => WithDefaultSourceResolution(searchPaths.AsImmutableOrEmpty());
/// <summary> /// Calculates the distance between two sequences of syntax nodes, disregarding trivia. /// </summary> /// <remarks> /// Distance is a number within [0, 1], the smaller the more similar the sequences are. /// </remarks> public static double ComputeDistance(IEnumerable <SyntaxNode> oldNodes, IEnumerable <SyntaxNode> newNodes) { return(LcsNodes.Instance.ComputeDistance(oldNodes.AsImmutableOrEmpty(), newNodes.AsImmutableOrEmpty())); }
/// <summary> /// Creates a top level code action with multiple code action choices a user can invoke. /// </summary> public static CodeAction Create(string title, IEnumerable<CodeAction> nestedActions, string equivalenceKey = null) { if (title == null) { throw new ArgumentNullException(nameof(title)); } return new SimpleCodeAction(title, nestedActions.AsImmutableOrEmpty(), equivalenceKey); }
/// <summary> /// Calculates the edits that transform one sequence of syntax nodes to another, disregarding trivia. /// </summary> public static IEnumerable <SequenceEdit> GetSequenceEdits(IEnumerable <SyntaxNode>?oldNodes, IEnumerable <SyntaxNode>?newNodes) => LcsNodes.Instance.GetEdits(oldNodes.AsImmutableOrEmpty(), newNodes.AsImmutableOrEmpty());
/// <summary> /// Calculates the edits that transform one sequence of syntax tokens to another, disregarding trivia. /// </summary> public static IEnumerable <SequenceEdit> GetSequenceEdits(IEnumerable <SyntaxToken>?oldTokens, IEnumerable <SyntaxToken>?newTokens) => LcsTokens.Instance.GetEdits(oldTokens.AsImmutableOrEmpty(), newTokens.AsImmutableOrEmpty());
/// <summary> /// Calculates the distance between two sequences of syntax tokens, disregarding trivia. /// </summary> /// <remarks> /// Distance is a number within [0, 1], the smaller the more similar the sequences are. /// </remarks> public static double ComputeDistance(IEnumerable <SyntaxToken>?oldTokens, IEnumerable <SyntaxToken>?newTokens) => LcsTokens.Instance.ComputeDistance(oldTokens.AsImmutableOrEmpty(), newTokens.AsImmutableOrEmpty());
/// <summary> /// Calculates the distance between two sequences of syntax nodes, disregarding trivia. /// </summary> /// <remarks> /// Distance is a number within [0, 1], the smaller the more similar the sequences are. /// </remarks> public static double ComputeDistance(IEnumerable <SyntaxNode>?oldNodes, IEnumerable <SyntaxNode>?newNodes) => LcsNodes.Instance.ComputeDistance(oldNodes.AsImmutableOrEmpty(), newNodes.AsImmutableOrEmpty());
public SuppressionCodeAction(Diagnostic diagnostic, IEnumerable<CodeAction> nestedActions) : base(string.Format(FeaturesResources.Suppress_0, diagnostic.Id), nestedActions.AsImmutableOrEmpty()) { }
public SuppressionCodeAction(Diagnostic diagnostic, IEnumerable <CodeAction> nestedActions) : base(string.Format(FeaturesResources.Suppress_0, diagnostic.Id), nestedActions.AsImmutableOrEmpty()) { }
/// <summary> /// Returns <see cref="MetadataReferenceProperties"/> with specified aliases. /// </summary> /// <exception cref="ArgumentException"> /// <see cref="Kind"/> is <see cref="MetadataImageKind.Module"/>, as modules can't be aliased. /// </exception> public MetadataReferenceProperties WithAliases(IEnumerable <string> aliases) { return(WithAliases(aliases.AsImmutableOrEmpty())); }
public SuppressionCodeAction(Diagnostic diagnostic, IEnumerable <CodeAction> nestedActions) : base(string.Format(FeaturesResources.SuppressionCodeActionTitle, diagnostic.Id), nestedActions.AsImmutableOrEmpty(), ComputeEquivalenceKey(nestedActions)) { }
public LanguageCompilationOptions WithUsings(IEnumerable <string> usings) => WithUsings(usings.AsImmutableOrEmpty());
public static CSharpGeneratorDriver Create(IEnumerable <ISourceGenerator> generators, IEnumerable <AdditionalText>?additionalTexts = null, CSharpParseOptions?parseOptions = null, AnalyzerConfigOptionsProvider?optionsProvider = null) // https://github.com/dotnet/roslyn/issues/46623 - can remove suppression when me make it internal #pragma warning disable CS0618 // Type or member is obsolete => new CSharpGeneratorDriver(parseOptions ?? CSharpParseOptions.Default, generators.ToImmutableArray(), optionsProvider ?? CompilerAnalyzerConfigOptionsProvider.Empty, additionalTexts.AsImmutableOrEmpty());
public SuppressionCodeAction(Diagnostic diagnostic, IEnumerable<CodeAction> nestedActions) : base(string.Format(FeaturesResources.SuppressionCodeActionTitle, diagnostic.Id), nestedActions.AsImmutableOrEmpty(), ComputeEquivalenceKey(nestedActions)) { }