Files
ILSpy/TestPlugin/CustomOptionsViewModel.cs
Siegfried Pammer 51aafa0fd9 Move ILSpy UI code back to the ICSharpCode.ILSpy root namespace
The Avalonia port had placed the UI app in an ILSpy.* namespace tree,
while the csproj RootNamespace and every prior release (through 10.1)
use ICSharpCode.ILSpy.*. Restoring the historical namespace reduces the
public API diff against release/10.1 for plugin authors and removes the
shadowing that forced global:: qualifiers in the test project. The
Images class and AccessOverlayIcon enum move back into the root
namespace (as in 10.1), since an ICSharpCode.ILSpy.Images namespace
would shadow the Images class for all code inside ICSharpCode.ILSpy.

Assisted-by: Claude:claude-fable-5:Claude Code
2026-06-12 21:12:07 +02:00

66 lines
1.8 KiB
C#

// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
using System.Composition;
using System.Xml.Linq;
using CommunityToolkit.Mvvm.ComponentModel;
using ICSharpCode.ILSpyX.Settings;
using ICSharpCode.ILSpy;
using ICSharpCode.ILSpy.Options;
namespace TestPlugin
{
// The Options host renders an [ExportOptionPage] viewmodel by resolving its view through the
// app-wide ViewLocator (SomeViewModel -> SomeView, searched across every loaded assembly,
// including plugins). So this viewmodel pairs with CustomOptionsView.axaml by name.
[ExportOptionPage(Order = 0)]
[Shared]
public sealed partial class CustomOptionsViewModel : ObservableObject, IOptionPage
{
public string Title => "TestPlugin";
[ObservableProperty]
private Options options = null!;
public void Load(SettingsService settings)
{
Options = settings.GetSettings<Options>();
}
public void LoadDefaults()
{
Options.LoadFromXml(new XElement("dummy"));
}
}
public sealed partial class Options : ObservableObject, ISettingsSection
{
static readonly XNamespace ns = "http://www.ilspy.net/testplugin";
[ObservableProperty]
private bool uselessOption1;
[ObservableProperty]
private double uselessOption2;
public XName SectionName { get; } = ns + "CustomOptions";
public void LoadFromXml(XElement e)
{
UselessOption1 = (bool?)e.Attribute("useless1") ?? false;
UselessOption2 = (double?)e.Attribute("useless2") ?? 50.0;
}
public XElement SaveToXml()
{
var section = new XElement(SectionName);
section.SetAttributeValue("useless1", UselessOption1);
section.SetAttributeValue("useless2", UselessOption2);
return section;
}
}
}