Browse Source

Fixed SD2-1239: ResourceToolkit: Incorrect mapping of manifest resource names to file names in VB.

In a VB project, the addin now searches the project root folder and all included project folders when looking for a resource file.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.1@2219 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Christian Hornung 19 years ago
parent
commit
4ac2c6f933
  1. 31
      src/AddIns/Misc/ResourceToolkit/Project/Src/Resolver/NRefactoryResourceResolver.cs

31
src/AddIns/Misc/ResourceToolkit/Project/Src/Resolver/NRefactoryResourceResolver.cs

@ -184,6 +184,35 @@ namespace Hornung.ResourceToolkit.Resolver
if (resourceName.StartsWith(p.RootNamespace, StringComparison.InvariantCultureIgnoreCase)) { if (resourceName.StartsWith(p.RootNamespace, StringComparison.InvariantCultureIgnoreCase)) {
if (p.Language == "VBNet") {
// SD2-1239
// The VB MSBuild tasks do not use the folder names
// in the manifest resource names.
// We have to look in all folders of the project
// for a file with the specified resource name.
// Need to add a dummy extension so that FindResourceFileName
// does not remove parts of the actual file name when it
// contains a dot.
string fileNameWithDummyExtension = String.Concat(resourceName.Substring(p.RootNamespace.Length+1), ".x");
// Search in the project root folder
// (this folder is not specified explicitly in
// the MSBuild project)
if ((fileName = FindResourceFileName(Path.Combine(p.Directory, fileNameWithDummyExtension))) != null) {
return new ResourceSetReference(resourceName, fileName);
}
// Search in all project folders
foreach (ProjectItem folder in p.GetItemsOfType(ItemType.Folder)) {
if ((fileName = FindResourceFileName(Path.Combine(folder.FileName, fileNameWithDummyExtension))) != null) {
return new ResourceSetReference(resourceName, fileName);
}
}
} else {
// Look for a resource file in the project with the exact name. // Look for a resource file in the project with the exact name.
if ((fileName = FindResourceFileName(Path.Combine(p.Directory, resourceName.Substring(p.RootNamespace.Length+1).Replace('.', Path.DirectorySeparatorChar)))) != null) { if ((fileName = FindResourceFileName(Path.Combine(p.Directory, resourceName.Substring(p.RootNamespace.Length+1).Replace('.', Path.DirectorySeparatorChar)))) != null) {
return new ResourceSetReference(resourceName, fileName); return new ResourceSetReference(resourceName, fileName);
@ -191,6 +220,8 @@ namespace Hornung.ResourceToolkit.Resolver
} }
}
// SharpDevelop silently strips the (hard-coded) folder names // SharpDevelop silently strips the (hard-coded) folder names
// "src" and "source" when generating the default namespace name // "src" and "source" when generating the default namespace name
// for new files. // for new files.

Loading…
Cancel
Save