Skip to content
This repository was archived by the owner on Jul 21, 2025. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions ILSpy.Core/ILSpySettings.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
//
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
Expand All @@ -30,23 +30,23 @@ namespace ICSharpCode.ILSpy
public class ILSpySettings
{
readonly XElement root;

ILSpySettings()
{
this.root = new XElement("ILSpy");
}

ILSpySettings(XElement root)
{
this.root = root;
}

public XElement this[XName section] {
get {
return root.Element(section) ?? new XElement(section);
}
}

/// <summary>
/// Loads the settings file from disk.
/// </summary>
Expand All @@ -66,12 +66,12 @@ public static ILSpySettings Load()
}
}
}

static XDocument LoadWithoutCheckingCharacters(string fileName)
{
return XDocument.Load(fileName, LoadOptions.None);
}

/// <summary>
/// Saves a setting section.
/// </summary>
Expand All @@ -86,7 +86,7 @@ public static void SaveSettings(XElement section)
root.Add(section);
});
}

/// <summary>
/// Updates the saved settings.
/// We always reload the file on updates to ensure we aren't overwriting unrelated changes performed
Expand All @@ -111,26 +111,26 @@ public static void Update(Action<XElement> action)
doc.Save(config, SaveOptions.None);
}
}

static string GetConfigFile()
{
if (App.CommandLineArguments.ConfigFile != null)
return App.CommandLineArguments.ConfigFile;
string localPath = Path.Combine(AppContext.BaseDirectory, "ILSpy.xml");
if (File.Exists(localPath))
return localPath;
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "ILSpy.xml");
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData, Environment.SpecialFolderOption.DoNotVerify), "ILSpy.xml");
}

const string ConfigFileMutex = "01A91708-49D1-410D-B8EB-4DE2662B3971";

/// <summary>
/// Helper class for serializing access to the config file when multiple ILSpy instances are running.
/// </summary>
sealed class MutexProtector : IDisposable
{
readonly Mutex mutex;

public MutexProtector(string name)
{
bool createdNew;
Expand All @@ -142,7 +142,7 @@ public MutexProtector(string name)
}
}
}

public void Dispose()
{
mutex.ReleaseMutex();
Expand Down