public void TryApplyWorksThrowsIfChangeIsDisallowedForParseOption() { // If we don't support the main change kind, then the other method should be called using var workspace = new CustomizedCanApplyWorkspace( allowedKinds: new ApplyChangesKind[] { }, canApplyParseOptions: (_, newParseOptions) => newParseOptions.Features["Feature"] == "ExpectedValue" ); var project = workspace.CurrentSolution.Projects.Single(); var exception = Assert.Throws <NotSupportedException>( () => workspace.TryApplyChanges( project.WithParseOptions( project.ParseOptions !.WithFeatures( new[] { KeyValuePairUtil.Create("Feature", "WrongThing") } ) ).Solution ) ); Assert.Equal( WorkspacesResources.Changing_parse_options_is_not_supported, exception.Message ); }
public void TryApplyWorksThrowsIfChangeIsDisallowedForCompilationOption() { // If we don't support the main change kind, then the other method should be called using var workspace = new CustomizedCanApplyWorkspace( allowedKinds: new ApplyChangesKind[] { }, canApplyCompilationOptions: (_, newCompilationOptions) => newCompilationOptions.MainTypeName == "Expected" ); var project = workspace.CurrentSolution.Projects.Single(); var exception = Assert.Throws <NotSupportedException>( () => workspace.TryApplyChanges( project.WithCompilationOptions( project.CompilationOptions !.WithMainTypeName("WrongThing") ).Solution ) ); Assert.Equal( WorkspacesResources.Changing_compilation_options_is_not_supported, exception.Message ); }
public void TryApplyWorksWhenAddingEditorConfigWithoutSupportingCompilationOptionsChanging() { using var workspace = new CustomizedCanApplyWorkspace(allowedKinds: ApplyChangesKind.AddAnalyzerConfigDocument); var project = workspace.CurrentSolution.Projects.Single(); Assert.True(workspace.TryApplyChanges(project.AddAnalyzerConfigDocument(".editorconfig", SourceText.From("")).Project.Solution)); }
public void TryApplyWorksSpecificChangeIsAllowedForCompilationOption() { // If we don't support the main change kind, then the other method should be called using var workspace = new CustomizedCanApplyWorkspace( allowedKinds: new ApplyChangesKind[] { }, canApplyCompilationOptions: (_, newCompilationOptions) => newCompilationOptions.MainTypeName == "Test"); var project = workspace.CurrentSolution.Projects.Single(); Assert.True(workspace.TryApplyChanges(project.WithCompilationOptions(project.CompilationOptions !.WithMainTypeName("Test")).Solution)); }
public void TryApplyWorksSpecificChangeIsAllowedForParseOption() { // If we don't support the main change kind, then the other method should be called using var workspace = new CustomizedCanApplyWorkspace( allowedKinds: new ApplyChangesKind[] { }, canApplyParseOptions: (_, newParseOptions) => newParseOptions.Features["Feature"] == "ExpectedValue"); var project = workspace.CurrentSolution.Projects.Single(); Assert.True( workspace.TryApplyChanges( project.WithParseOptions(project.ParseOptions !.WithFeatures(new[] { KeyValuePairUtil.Create("Feature", "ExpectedValue") })).Solution)); }