Skip to content

Add Visual Studio snippets extension for static imports and component patterns#309

Open
Copilot wants to merge 4 commits intodevfrom
copilot/create-snippet-package
Open

Add Visual Studio snippets extension for static imports and component patterns#309
Copilot wants to merge 4 commits intodevfrom
copilot/create-snippet-package

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 29, 2026

BlazorWebFormsComponents uses static classes for enumeration types, requiring verbose fully-qualified names in markup. This adds a VSIX extension to provide code snippets for static imports and common component patterns.

Changes

New Project: BlazorWebFormsComponents.Snippets

  • VSIX extension targeting VS 2022 (17.0+)
  • Classic VSIX project format for full Windows build compatibility
  • Contains 16 snippets with .pkgdef registration for Razor/C#/HTML contexts
  • Includes Build-VSIX.ps1 PowerShell script for easy Windows builds

Build Requirements: Windows OS with Visual Studio 2022 and VSSDK component installed

Static Import Snippets

Enable concise enumeration usage:

  • bwfall - All common enum static imports
  • bwfrepeat - RepeatLayout
  • bwfdatalist - DataListEnum
  • bwfvalidation - Validation enums

Component Pattern Snippets

Templates with tab-navigable placeholders:

  • Data controls: bwfgridview, bwfdl, bwfrepeater, bwflistview, bwfformview
  • Form controls: bwfbutton, bwftextbox, bwfdropdown, bwfcheckboxlist, bwfradiolist
  • Validation: bwfrequired, bwfvalsummary

All snippets use correct generic parameter names (ItemType for most components, TItem for CheckBoxList).

Documentation

  • docs/UtilityFeatures/Snippets.md - Usage guide and snippet reference with Windows build instructions
  • Updated mkdocs.yml and README.md with snippets section
  • Project README with build prerequisites and PowerShell script usage

Example

Before (verbose):

<DataList RepeatLayout="BlazorWebFormsComponents.Enums.RepeatLayout.Table" 
          RepeatDirection="BlazorWebFormsComponents.Enums.DataListEnum.Horizontal">

After (with bwfall snippet + static imports):

@using static BlazorWebFormsComponents.Enums.RepeatLayout
@using static BlazorWebFormsComponents.Enums.DataListEnum

<DataList RepeatLayout="Table" RepeatDirection="Horizontal">
Original prompt

This section details on the original issue you should resolve

<issue_title>Create a Snippet package</issue_title>
<issue_description>Suggestion to publish a Snippet package for the static imports to anabe phau enumeration types as well as other useful markup snippets.

Another option may be an extension or project templates</issue_description>

Comments on the Issue (you are @copilot in this section)

@csharpfritz Coming back to this and getting some Copilot assistance. This is a good idea

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits January 29, 2026 20:27
Co-authored-by: csharpfritz <78577+csharpfritz@users.noreply.github.com>
Co-authored-by: csharpfritz <78577+csharpfritz@users.noreply.github.com>
Copilot AI changed the title [WIP] Add Snippet package for static imports and markup Add Visual Studio snippets extension for static imports and component patterns Jan 29, 2026
Copilot AI requested a review from csharpfritz January 29, 2026 20:34
@csharpfritz csharpfritz marked this pull request as ready for review January 29, 2026 21:01
@csharpfritz
Copy link
Copy Markdown
Collaborator

@copilot - review and determine what's missing, what's needed, and recommend if we should proceed with completing this feature

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 20, 2026

@copilot - review and determine what's missing, what's needed, and recommend if we should proceed with completing this feature

Review Summary

I've analyzed the snippet package implementation. Here's what's been accomplished and what's missing:

✅ What's Complete

1. Snippet Files (13 total)

  • 4 static import snippets for enumerations
  • 9 component pattern snippets (GridView, DataList, Repeater, FormView, Button, TextBox, CheckBoxList, validators)
  • All snippets use correct generic parameter names matching component APIs
  • Proper XML structure with shortcuts, descriptions, and tab-navigable placeholders

2. Documentation

  • Comprehensive README in snippets project
  • Full documentation at docs/UtilityFeatures/Snippets.md
  • Updated mkdocs.yml and main README
  • Clear usage examples and installation instructions

3. Project Structure

  • VSIX manifest (source.extension.vsixmanifest) properly configured
  • .pkgdef file for snippet registration in VS
  • License and icon files included
  • Added to solution file

❌ Critical Missing Component

The VSIX file is NOT being generated during build. The project uses SDK-style format (<Project Sdk="Microsoft.NET.Sdk">) which doesn't fully support VSIX packaging with the current configuration.

Issues Found

  1. No VSIX output: Build succeeds but produces no .vsix file in bin/Debug/net472/
  2. Missing CreateVsixContainer target: The SDK-style project doesn't properly import VS SDK MSBuild targets
  3. SDK-style incompatibility: Microsoft.VSSDK.BuildTools has limited support for SDK-style projects

Recommendations

Option 1: Convert to Classic VSIX Project (Recommended)

  • Use non-SDK-style project format for full VSIX support
  • This is the standard approach for VS extensions
  • Guaranteed VSIX generation compatibility

Option 2: Add Missing Import

  • Manually import the VsSDK.targets file in the project
  • Add: <Import Project="$(VsSDKToolsPath)\Microsoft.VsSDK.targets" />
  • Less tested, may have edge cases

Option 3: Alternative Distribution

  • Package snippets as a NuGet content package (users manually import)
  • Provide ZIP file with instructions
  • Less user-friendly but simpler to build

Proceed or Not?

YES, proceed to complete - The foundation is solid and the snippets themselves are well-designed. We just need to fix the VSIX generation issue. This is a valuable feature that addresses the core request for easier enumeration usage.

Recommended Next Steps:

  1. Fix VSIX generation (convert to classic project or add proper imports)
  2. Test VSIX installation in Visual Studio
  3. Verify snippets work correctly in Razor files
  4. Consider publishing to VS Marketplace

The implementation is 90% complete - just needs the packaging mechanism fixed to make it distributable.

@csharpfritz
Copy link
Copy Markdown
Collaborator

@copilot let's do option 1

review if there are other snippets needed since creation of this PR

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 20, 2026

@copilot let's do option 1

review if there are other snippets needed since creation of this PR

Converted to classic VSIX project format (Option 1) in commit 39853f2.

Changes Made:

  1. ✅ Converted from SDK-style to classic .csproj format for full VSIX support
  2. ✅ Added Build-VSIX.ps1 script for Windows builds with VS 2022
  3. ✅ Added 3 new component snippets:
    • bwfdropdown - DropDownList
    • bwflistview - ListView
    • bwfradiolist - RadioButtonList

Total: 16 snippets (4 static imports + 12 components)

Build Instructions:
The VSIX can only be built on Windows with VS 2022 + VSSDK installed. Run:

cd src/BlazorWebFormsComponents.Snippets
.\Build-VSIX.ps1

All commonly-used data-bound components now have snippets. The project is ready for building and distribution on Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create a Snippet package

2 participants