|
This page describes what types of resource references the ResourceToolkit addin is able to detect. System.Resources.ResourceManager or derived classes:- The ResourceManager constructor
new ResourceManager("ProjectNamespace.ResourceName", currentProjectAssembly) must be used to initialize the resource manager variable. - The following types of variables are resolved correctly:
- local variables which are initialized directly in the declaration
- static or instance fields which are initialized directly in the declaration
- static or instance fields which are initialized by an assignment in the same file as the declaration is in (the field in the initialization line must be prefixed with the class name or
this in order to be found) - static or instance properties which reference a field meeting the criteria above and which differ from the field name only in case
- The resource name is mapped to the directory structure just as MSBuild does it. However, the resource file will not be found if any subdirectory name contains a dot.
In addition to the ResourceManager's GetString and GetObject methods, a resource access using an indexer is also detected. This is not supported by the default .NET ResourceManager, but can be added using a simple derived class like this: This would allow accessing resources like this: myResourceManager["MyKey"], which makes the code less verbose than using GetString.
ICSharpCode.Core- The ResourceToolkit addin also detects resource references using
ICSharpCode.Core (${res:...}). Tooltips work in all files, whereas code completion only works in files that use SharpDevelop's default text editor (especially it does NOT work in XML files). Code completion is triggered by typing the colon in ${res: and it lists all accessible resource entries, both those of the local project and those of the host application, which is useful when developing addins for the host application.
 - When adding new resources, they are added to the local project resource file if that is found, or to the host application resource file otherwise.
- The resource files are searched for in the standard locations used by SharpDevelop itself and the ICSharpCode core demo application and the host application is located using the reference to the ICSharpCode.Core library. These files are searched for the local project resources:
<ProjectDirectory>\StringResources.resources<ProjectDirectory>\StringResources.resx<ProjectDirectory>\Resources\StringResources.resources<ProjectDirectory>\Resources\StringResources.resx
- These files are searched for the host application resources:
<PathToICSharpCodeCoreDll>\..\src\Main\StartUp\Project\Resources\StringResources.resources<PathToICSharpCodeCoreDll>\..\src\Main\StartUp\Project\Resources\StringResources.resx<PathToICSharpCodeCoreDll>\..\StartUp\Project\Resources\StringResources.resources<PathToICSharpCodeCoreDll>\..\StartUp\Project\Resources\StringResources.resx<PathToICSharpCodeCoreDll>\..\StartUp\Resources\StringResources.resources<PathToICSharpCodeCoreDll>\..\StartUp\Resources\StringResources.resx<PathToICSharpCodeCoreDll>\..\StartUp\StringResources.resources<PathToICSharpCodeCoreDll>\..\StartUp\StringResources.resx
The resource resolver system has been improved in version 2.1 by making more use of SharpDevelop's expression resolution capabilities and should be able to detect resource references in more cases.
The following list only includes the major differences to what is already described for version 2.0 above. System.Resources.ResourceManager or derived classes:- The ResourceManager constructor
new ResourceManager(typeof(MyClass)) is also supported. - Properties and fields are correctly mapped to each other even if they do not have names that differ only in case as long as the first return statement in the getter or the first assignment in the setter refers to the desired field.
- References are detected correctly if the type of the assigned resource manager object does not match the type of the variable.
ICSharpCode.CoreResourceService.GetString("ResourceKey") calls are detected.- The list of possible locations of the resource files can be edited in the addin file. However, currently there can only be one file for the local application and one file for the host application.
|