SS Refactor
Overview
# SS Refactor from Site Sculptors is a Visual Studio extension that provides context menu commands to convert C# properties between MVVM patterns, including [ObservableProperty]
(CommunityToolkit.Mvvm), auto-properties, and full properties. It works with auto-properties, full properties, Prism-style properties, and most common MVVM property patterns. It is compatible with both Visual Studio 2022 and Visual Studio 2026 .
Features
- Convert to ObservableProperty: Converts auto-properties, full properties (block-bodied, expression-bodied, SetProperty, Prism-style, etc.) to
[ObservableProperty]
fields.
- Convert to AutoProperty: Converts full properties and observable fields to auto-properties (
{ get; set; }
).
- Convert to FullProperty: Converts auto-properties and observable fields to full MVVM properties using a backing field and
SetProperty
pattern.
- Context menu integration for quick access.
- Robust property detection for adjacent and variably formatted properties.
- Always generates fields with underscore prefix (e.g.,
_name
).
- Automatically adds
using CommunityToolkit.Mvvm.ComponentModel;
if missing.
- Checks for CommunityToolkit.Mvvm NuGet package and guides user to install if missing (with clipboard and NuGet UI support).
- Ensures containing class is partial, with prompt to make it partial if needed.
- Skips and warns about properties that cannot be safely converted.
- Supports .NET Framework 4.7.2 and Visual Studio 2022 or later.
How to Use
- Highlight one or more properties in your C# code (auto, full, or Prism-style).
- Right-click to open the context menu.
- Select one of the conversion commands:
- Convert to ObservableProperty
- Convert to AutoProperty
- Convert to FullProperty
- The selected properties will be replaced with the chosen property pattern.
Examples
Auto-Property Example
// Before:
public string Name { get; set; }
// After (ObservableProperty):
[ObservableProperty]
private string _name;
// After (FullProperty):
private string _name;
public string Name
{
get => _name;
set => SetProperty(ref _name, value);
}
Full Property Example
// Before:
private bool isBusy;
public bool IsBusy
{
get => isBusy;
set => SetProperty(ref isBusy, value);
}
// After (ObservableProperty):
[ObservableProperty]
private bool _isBusy;
// After (AutoProperty):
public bool IsBusy { get; set; }
Prism-Style Property Example
// Before:
private string myVar;
public string MyProperty
{
get { return myVar; }
set { myVar = value; RaisePropertyChanged(); }
}
// After (ObservableProperty):
[ObservableProperty]
private string _myProperty;
Requirements
- Visual Studio 2022 (v17.0 or later)
- .NET Framework 4.7.2 or later
Installation
Download and install the VSIX from the Visual Studio Marketplace or from the Releases page.
Documentation & Support
License
MIT