Aller au contenu
Skillpedia
API et serveurs (backend)40k · #7402

resx-source-generator-migration

Ce qu’il fait

Ce code vous aide à mettre à jour vos projets logiciels. Il remplace une ancienne méthode de gestion des fichiers de ressources (textes, messages) par une méthode plus moderne et plus efficace, grâce à un « générateur de code source ».

Quand l’utiliser

  • ✓Lorsque vous voulez moderniser un ancien projet.
  • ✓Lorsque vous cherchez à optimiser les performances de votre programme.
  • ✓Pour simplifier la gestion des textes.

Lien du skill

https://github.com/github/awesome-copilot/blob/main/skills/resx-source-generator-migration/SKILL.md

Copiez-le et collez-le dans votre IA (Claude, ChatGPT ou Cursor) en lui demandant de suivre les instructions.

Comment l’utiliser

Le plus simple : copiez le message et collez-le dans votre IA. Elle lit le skill et suit les instructions.

Message prêt à coller

Utilise ce skill pour m’aider : https://github.com/github/awesome-copilot/blob/main/skills/resx-source-generator-migration/SKILL.md Lis le fichier SKILL.md de ce lien et suis ses instructions pour ma tâche.
Envie que votre IA trouve seule des skills comme celui-ci ?Installez le MCP gratuit de Skillpedia : une ligne, et elle cherche parmi 15 000+ skills avant chaque tâche.Installer en 1 minute →

Exemple de demande à votre IA

“Migrez mon projet « MyProject.csproj » pour utiliser le générateur de code source pour les fichiers .resx.”

5 nouveaux skills par semaine. 1 minute de lecture.

Comment ça marche

Il ajoute un nouvel outil à votre projet et supprime les anciennes configurations qui créaient des fichiers de code supplémentaires. L'accès aux textes du code est ainsi généré automatiquement.

Contenu technique (SKILL.md original)

Texte original de l’auteur, en anglais, directement depuis GitHub.

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:

  1. If the repository centrally manages package versions and already has a PackageVersion for Microsoft.CodeAnalysis.ResxSourceGenerator, add this versionless reference to an ItemGroup in the project file:
<PackageReference Include="Microsoft.CodeAnalysis.ResxSourceGenerator" PrivateAssets="all" />
  1. 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 PackageReference or add the corresponding central PackageVersion.
  2. 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:

  • LastGenOutput metadata on the EmbeddedResource item;
  • a Compile item whose DependentUpon metadata names the .resx file; and
  • a matching *.Designer.cs file on disk, even when the SDK includes it implicitly and no Compile item 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:

  1. Delete the *.Designer.cs file from disk.
  2. Remove its explicit MSBuild item from the project when one exists.

Update EmbeddedResource items

…

Questions fréquentes

Que sont les fichiers .resx ?

Ce sont des fichiers qui stockent les textes et messages utilisés dans votre programme, comme les libellés de boutons ou les messages d'erreur, pour faciliter la traduction et la gestion de ces textes.

Qu'est-ce qu'un « générateur de code source » ?

C'est un outil qui écrit automatiquement du code pour vous, à partir d'autres informations. Dans ce cas, il génère le code permettant d'accéder aux textes des fichiers .resx.

Dois-je me soucier des fichiers .Designer.cs ?

Non, le but de cette mise à jour est justement de supprimer le besoin de ces fichiers .Designer.cs générés automatiquement, pour un processus plus propre.

Détails

Description originale de l’auteur

Migrates a project that uses checked-in .designer.cs files behind .resx to using a source-generator instead

repo: github/awesome-copilot

Popularité

Étoiles GitHub
40k
Position au classement
#7402
Licence
MIT
Mis à jour
15/10/2026

Ce skill vous est-il utile ?

0

Connectez-vous pour voter.

Commentaires

  • …

Autres skills de ce dépôt

Skills similaires