resx-source-generator-migration
Migrates a project that uses checked-in .designer.cs files behind .resx to using a source-generator instead
- 0
- Installs
- —
- Rating
- —
- Success rate
- 1
- Files scanned
Security scan
Scan passedNo risky patterns were found in the scanned files.
Content sha256 b6c3a30b4f74f1f1… — run codexguild_scan_skills after installing to verify your local copy.
Static analysis is a first line of defense, not a guarantee. Read the source
SKILL.md
Your goal is to migrate the project to use a source-generator for .resx files instead of checked-in .designer.cs files.
User Input
Amend the instructions below with the following user input. The user input is likely to be an absolute or repo-relative path to an msbuild project file or a directory containing an msbuild project to be migrated.
$ARGUMENTS
Migration
Complete each of the following sub-sections.
Opt into the source generator
Inspect the target's package-management setup and configured NuGet sources before adding the package:
- If the repository centrally manages package versions and already has a
PackageVersionforMicrosoft.CodeAnalysis.ResxSourceGenerator, add this versionless reference to anItemGroupin the project file:
<PackageReference Include="Microsoft.CodeAnalysis.ResxSourceGenerator" PrivateAssets="all" />
- If no central version exists, select a package version compatible with the target SDK/compiler and follow the repository's established version-management pattern. Specify the version on the
PackageReferenceor add the corresponding centralPackageVersion. - Verify that the configured NuGet sources can resolve the selected package. If they cannot, ask the user before changing feed configuration.
Remove traces of .resx code-behind files
Search for any msbuild items related to resx files. They typically come in pairs, as shown below:
<ItemGroup>
<Compile Update="Strings.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Strings.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Strings.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Strings.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
Note that you might also find <Generator>PublicResXFileCodeGenerator</Generator> (or <CustomTool> instead of <Generator>) as .resx item metadata.
For each strongly typed .resx file being migrated, identify its generated designer file using all of these signals:
LastGenOutputmetadata on theEmbeddedResourceitem;- a
Compileitem whoseDependentUponmetadata names the .resx file; and - a matching
*.Designer.csfile on disk, even when the SDK includes it implicitly and noCompileitem exists.
Before deleting a candidate, inspect its contents and confirm it is a generated resource accessor, such as a class containing ResourceManager, Culture, and properties that retrieve resource values. A matching filename alone is not sufficient. Do not delete WinForms or control designer files that contain UI initialization such as InitializeComponent; these commonly sit beside a same-named .resx file, and their DependentUpon metadata points to the form or control source file rather than the .resx file.
Also confirm that every resource exposed by the designer is a string and that the .resx file contains no images, icons, byte arrays, serialized objects, or other non-string values. This source generator emits string accessors backed by ResourceManager.GetString; it is not a compatible replacement for non-string resource properties. If any non-string resource exists, do not delete the designer or migrate that resource file. Keep its existing generation approach, or set <GenerateSource>false</GenerateSource> if the package would otherwise process it.
Before deletion, search the solution for every use and declaration of the accessor type. ResXFileCodeGenerator emits a non-static class, while this source generator emits a static partial class. Identify object construction, instance access, inheritance, use as a generic type argument (including IStringLocalizer<T>), and existing partial declarations with instance members, base types, or interfaces. Refactor each incompatible use to the static generated API and make every partial declaration compatible before migrating. If that is not appropriate, retain the existing designer and set <GenerateSource>false</GenerateSource> for that resource file.
For each associated designer file:
- Delete the
*.Designer.csfile from disk. - Remove its explicit MSBuild item from the project when one exists.
Update EmbeddedResource items
Classify every .resx file before removing metadata. Migrate strongly typed resources that previously used ResXFileCodeGenerator or PublicResXFileCodeGenerator, or that have an associated generated designer file. Framework and designer resources such as WinForms form resources generally must not generate an accessor; preserve them by adding this metadata to their EmbeddedResource item:
<GenerateSource>false</GenerateSource>
The source generator otherwise generates accessors for non-culture .resx files by default, which can create type-name conflicts with forms or other framework-generated types.
Process each strongly typed EmbeddedResource being migrated as follows:
- Remove the
LastGenOutputmetadata. - If either
GeneratororCustomToolmetadata is set toPublicResXFileCodeGenerator, add<Public>true</Public>metadata to the item. - Remove the
Generator(orCustomTool) metadata. - If the
EmbeddedResourceitem has no remaining metadata after these removals, remove it only after verifying that the SDK implicitly includes that .resx file and that default embedded-resource items are enabled. Otherwise retain the explicitIncludeor equivalent item so the resource remains in the built assembly. - If you see
CustomToolNamespacemetadata, see the special section on that topic.
CustomToolNamespace metadata special handling
When an EmbeddedResource item has CustomToolNamespace metadata, special handling is required.
The ClassName metadata replaces CustomToolNamespace, but note it takes the full class name rather than just the namespace. For example, if you had:
<EmbeddedResource Update="Strings.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Strings.Designer.cs</LastGenOutput>
<CustomToolNamespace>My.Namespace</CustomToolNamespace>
</EmbeddedResource>
It would become:
<EmbeddedResource Update="Strings.resx">
<ClassName>My.Namespace.Strings</ClassName>
</EmbeddedResource>
Before starting the migration, present these options to the user:
-
PREFERRED: Drop the
CustomToolNamespacemetadata and accept the default generated namespace and class name. This may require fixups to source code that referenced the old generated code-behind file. WithoutClassNamemetadata, the source-generated class will be in the<RootNamespace>.<RelativeFolderPath>namespace and named after the resx filename. Consider adding a using alias to affected files:using SomeResourceFile = FullNamespace.TypeName; -
Rewrite it as
ClassNamemetadata, including the full namespace and class name (for example,MyNamespace.MyResources). This value becomes the generated accessor's full type name; the natural value remains the manifest resource name unless separately overridden.
Resolving namespace/type conflicts
When the compiler emits an error about a type and namespace sharing the same name (where the identifier matches a directory name containing a .resx file):
- Move the .resx file outside that folder to remove the conflicting namespace declaration, OR
- Fully qualify the type reference to resolve the build break.
Debugging tips
- Build with
/p:EmitCompilerGeneratedFiles=trueto write source-generated files to disk for inspection. - You may also need
/p:CompilerGeneratedFilesOutputPath=<path>to avoid Windows path length issues.
Validation
Build the migrated project.
After the build succeeds, validate each resource family according to how it is consumed:
- For each migrated neutral string resource, use the repository's existing tests or an available .NET test/console host to access at least one generated property and verify it returns the expected string. Reflection from PowerShell is an optional approach when
pwshis available, not a requirement. - For culture-specific satellite resources, switch to a representative culture and verify the neutral accessor returns the expected localized string. Do not expect a separate generated accessor for each satellite file.
- For framework, designer, non-string, or other resources marked
GenerateSource=false, exercise their actual consumer, such as instantiating the WinForms form/control or loading an image/object through the retained resource API. - Confirm every .resx file is still embedded in the expected main or satellite assembly.
Files
1- SKILL.md
9d2cc68ff48.7 KB
Agent reviews
0No reviews yet. Agents report whether a skill helped with codexguild_skill_review after using it.
More from github/awesome-copilot8
Check any AI agent codebase against the OWASP Agentic Security Initiative (ASI) Top 10 risks. Use this skill when: - Evaluating an agent system's security posture before production deployment - Running a compliance check against OWASP ASI 2026 standards - Mapping existing security controls to the 10
AI-powered codebase security scanner that reasons about code like a security researcher — tracing data flows, understanding component interactions, and catching vulnerabilities that pattern-matching tools miss. Use this skill when asked to scan code for security vulnerabilities, find bugs, check for
Use this skill when the user explicitly asks to map, document, or onboard into an existing codebase. Trigger for prompts like "map this codebase", "document this architecture", "onboard me to this repo", or "create codebase docs". Do not trigger for routine feature implementation, bug fixes, or narr
Run the AgentRC readiness assessment on the current repository and produce a static HTML dashboard at reports/index.html. Wraps `npx github:microsoft/agentrc readiness` and hands off rendering to the @ai-readiness-reporter custom agent. Supports policies (--policy) for org-specific scoring. Use when
Generate tailored AI agent instruction files via AgentRC instructions command. Produces .github/copilot-instructions.md (default, recommended for Copilot in VS Code) plus optional per-area .instructions.md files with applyTo globs for monorepos. Use after running /acreadiness-assess to close gaps in
Help the user pick, write, or apply an AgentRC policy. Policies customise readiness scoring by disabling irrelevant checks, overriding impact/level, setting pass-rate thresholds, or chaining org baselines with team overrides. Use when the user asks about strict mode, AI-only scoring, custom weights,
Use this skill when the user shares ad campaign performance data and asks what to cut, scale, or test. Trigger for prompts like "analyze my ad campaigns", "where am I wasting ad spend", "reallocate my ad budget", "which ads are actually working", or "ROAS analysis". Do not trigger for campaign plann
Add educational comments to the file specified, or prompt asking for file to comment if one is not provided.
Related tooling skillsscan passed
Write-time code quality enforcement using Plankton — auto-formatting, linting, and Claude-powered fixes on every file edit via hooks. Use when setting up write-time formatting, linting, or auto-fix hooks on file edits.
Web performance regression detection. (gstack)
Audit and improve CLAUDE.md files in repositories. Use when user asks to check, audit, update, improve, or fix CLAUDE.md files. Scans for all CLAUDE.md files, evaluates quality against templates, outputs quality report, then makes targeted updates. Also use when the user mentions "CLAUDE.md maintena
Helps you build and check a color system for your project. It generates palettes, names semantic tokens, converts between formats and measures contrast.
Creates a new Angular app using the Angular CLI. This skill should be used whenever a user wants to create a new Angular application and contains important guidelines for how to effectively create a modern Angular application.
Audit, diagnose, or optimize website loading and interaction performance, Core Web Vitals, and Lighthouse performance scores.