Skip to content
This repository was archived by the owner on Oct 16, 2020. It is now read-only.

Commit d307bf8

Browse files
committed
Fixed #400: Indentation engine misbehaves when editing MSBuildBasedProject.cs.
Fixed CSharpBinding tests.
1 parent a441bb9 commit d307bf8

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormattingStrategy/CSharpFormattingOptionsContainer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ public CSharpFormattingOptions GetEffectiveOptions()
280280
/// <returns>Created and filled <see cref="ICSharpCode.NRefactory.CSharp.CSharpFormattingOptions"/> instance.</returns>
281281
private CSharpFormattingOptions CreateCachedOptions()
282282
{
283-
var outputOptions = FormattingOptionsFactory.CreateEmpty();
283+
var outputOptions = FormattingOptionsFactory.CreateSharpDevelop();
284284

285285
// Look at all container options and try to set identically named properties of CSharpFormattingOptions
286286
foreach (PropertyInfo propertyInfo in typeof(CSharpFormattingOptions).GetProperties()) {

src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormattingStrategy/CSharpFormattingOptionsPersistence.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,20 @@ public override void Execute(object parameter)
3939
/// </summary>
4040
internal class CSharpFormattingOptionsPersistence
4141
{
42+
static bool initialized;
4243
static Dictionary<string, CSharpFormattingOptionsPersistence> projectOptions;
4344

45+
static CSharpFormattingOptionsPersistence()
46+
{
47+
Initialize();
48+
}
49+
4450
public static void Initialize()
4551
{
52+
if (initialized)
53+
return;
54+
55+
initialized = true;
4656
projectOptions = new Dictionary<string, CSharpFormattingOptionsPersistence>();
4757

4858
// Load global settings
@@ -54,8 +64,11 @@ public static void Initialize()
5464
GlobalOptions.Load();
5565

5666
// Handlers for solution loading/unloading
57-
SD.ProjectService.SolutionOpened += SolutionOpened;
58-
SD.ProjectService.SolutionClosed += SolutionClosed;
67+
var projectService = SD.GetService<IProjectService>();
68+
if (projectService != null) {
69+
SD.ProjectService.SolutionOpened += SolutionOpened;
70+
SD.ProjectService.SolutionClosed += SolutionClosed;
71+
}
5972
}
6073

6174
public static CSharpFormattingOptionsPersistence GlobalOptions

0 commit comments

Comments
 (0)