FsXaml icon indicating copy to clipboard operation
FsXaml copied to clipboard

Avoiding exception in case when "LogicalName" wasn't provided for EmbeddedResource.

Open FoggyFinder opened this issue 7 years ago • 2 comments

Right now it's neccessary to specify LogicalName for EmbeddedResource like this:

<LogicalName>MainWindow.xaml</LogicalName>

I think it will be better to allow user skip this step or at least make it clearly what's went wrong. Current exception message just suggest checking that file is marked as Resource.

So, in function getEmbeddedResourceStream instead of:

let resourceName = 
    ass.GetManifestResourceNames()
    |> Array.tryFind (fun n -> n.ToLowerInvariant().Trim() = file.ToLowerInvariant().Trim())

use

let file' = file.ToLowerInvariant().Trim()
let resourceName = 
    ass.GetManifestResourceNames()
    |> Array.tryFind
           (fun n ->
               let n' = n.ToLowerInvariant().Trim()
               n' = file' || n' = ass.GetName().Name.ToLowerInvariant().Trim() + "." + file')

FoggyFinder avatar Mar 03 '19 12:03 FoggyFinder

Making this work with Resource and EmbeddedResource makes sense - I'm open to making this change provided it's tested and backwards compatible.

ReedCopsey avatar Mar 04 '19 18:03 ReedCopsey

Initially I've thought about just minimal changes - one additional condition for name checking

FoggyFinder avatar Mar 05 '19 09:03 FoggyFinder