I've added a small function in the Resources.Designer.cs and it working great, the problem is that when I add or remove something from the Resources.resx this function always get removed, is there any indicator I could put or anyway to bypass this?

Thank you!

Code in Resources.Designer.cs is automatically generated. Any code you put in there will be overwritten each time any change is made to the Resources file.

You could try making Resources partial and put your function in a seperate file.
This way only the partial key word is removed; you will still have to manualy put this back each time Resources are edited but at least you do not loose your code.
In Resources.Designer.cs

internal partial class Resources { //<-- add partial to Resources

In new class file

namespace MyProject.Properties
{
    partial class Resources
    {
        internal static void MyFunc()
        { 
            // do something
        }
    }
}

Isn't there a fancy way to create an extension method for a static class?

Your problem is that

Code in Resources.Designer.cs is automatically generated.

You might be able to do something using Extensibility (e.g. create an AddIn that monitors for changes to the Resouces.Designer.cs) but I'm not sure it is possible and is probably ott for what you want.

Note: The partial keyword is used to enable two (or more) source files to define a single class. The forms designer uses this to seperate user and autogenerated code.

You can also try deriving from Resouces

namespace MyProject.Properties
{
    class MyResources : Resources
    {
        internal static void MyFunc()
        {
            // do something
        }
    }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.