From 4ac2c6f93389d2e36bca4508e2e9b292144c15fd Mon Sep 17 00:00:00 2001 From: Christian Hornung Date: Thu, 28 Dec 2006 11:11:13 +0000 Subject: [PATCH] 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 --- .../Resolver/NRefactoryResourceResolver.cs | 37 +++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/src/AddIns/Misc/ResourceToolkit/Project/Src/Resolver/NRefactoryResourceResolver.cs b/src/AddIns/Misc/ResourceToolkit/Project/Src/Resolver/NRefactoryResourceResolver.cs index 340fe0950f..a0c7f494bc 100644 --- a/src/AddIns/Misc/ResourceToolkit/Project/Src/Resolver/NRefactoryResourceResolver.cs +++ b/src/AddIns/Misc/ResourceToolkit/Project/Src/Resolver/NRefactoryResourceResolver.cs @@ -184,9 +184,40 @@ namespace Hornung.ResourceToolkit.Resolver if (resourceName.StartsWith(p.RootNamespace, StringComparison.InvariantCultureIgnoreCase)) { - // 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) { - return new ResourceSetReference(resourceName, fileName); + 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. + if ((fileName = FindResourceFileName(Path.Combine(p.Directory, resourceName.Substring(p.RootNamespace.Length+1).Replace('.', Path.DirectorySeparatorChar)))) != null) { + return new ResourceSetReference(resourceName, fileName); + } + } }