Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9a1b930

Browse files
committed
Make mono/xbuild F# resource naming a bit more consistent with Visual F#
Seefsharp#50The comments in FSharpBuild/Fsc.fs explain a bit more. It is realy hardto work out how to make this perfectly consistent. Essentially, becareful using resources in folders if you want your projects to beportable across VisualStudio/MSBuild and mono/MonoDevelop/XBuildWe hit this bug in fsharp/fsharpbinding, but we've moved that to nolonger put resources in folders for now.
1 parentf0db0f9 commit9a1b930

File tree

1 file changed

+31
-4
lines changed

1 file changed

+31
-4
lines changed

‎src/fsharp/FSharp.Build/CreateFSharpManifestResourceName.fs‎

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,49 @@ type CreateFSharpManifestResourceName public () =
1414
(rootNamespace:string),(* may be null*)
1515
(dependentUponFileName:string),(* may be null*)
1616
(binaryStream:System.IO.Stream)(* may be null*)):string=
17+
18+
// The Visual CSharp and XBuild CSharp toolchains transform resource names like this:
19+
// SubDir\abc.resx --> SubDir.abc.resources
20+
// SubDir\abc.txt --> SubDir.abc.txt
21+
//
22+
// For resx resources, both the Visual FSharp and XBuild FSHarp toolchains do the right thing, i.e.
23+
// SubDir\abc.resx --> SubDir.abc.resources
24+
//
25+
// However for non-resx resources, for some reason Visual FSharp does _not_ add the directory name to the resource name.
26+
// It is very unclear where the directory name gets dropped in the Visual FSharp implementation
27+
// - is it in Microsoft.Common.targets, Microfost.FSharp.targets or how the base type CreateCSharpManifestResourceName
28+
// is created and used - who knows, the code is not easy to understand despite it doing something very simple. That's
29+
// the nature of MSBuild/XBuild....
30+
//
31+
// Anyway, dropping the directory name seems like a mistake. But we attempt to replicate the behaviour here
32+
// for consistency with Visual FSharp. This may not be the right place to do this and this many not be consistent
33+
// when cultures are used - that case has not been tested.
34+
35+
letfileName=if fileName.EndsWith(".resources", StringComparison.OrdinalIgnoreCase)then fileNameelse Path.GetFileName(fileName)
36+
letlinkFileName=if linkFileName.EndsWith(".resources", StringComparison.OrdinalIgnoreCase)then linkFileNameelse Path.GetFileName(linkFileName)
37+
1738
letembeddedFileName=
1839
match linkFileNamewith
1940
|null-> fileName
2041
|_-> linkFileName
42+
2143
// since we do not support resources dependent on a form, we always pass null for a binary stream
2244
// rootNamespace is always empty - we do not support it
23-
letcSharpResult=
24-
base.CreateManifestName(fileName, linkFileName,"", dependentUponFileName,null)
45+
letcSharpResult=base.CreateManifestName(fileName, linkFileName,"", dependentUponFileName,null)
46+
printfn"(fileName,linkFileName,embeddedFileName,rootNamespace) = '%A'"(fileName, linkFileName, embeddedFileName, rootNamespace)
47+
printfn"cSharpResult = '%s'" cSharpResult
2548
// Workaround that makes us keep .resources extension on both 3.5 and 3.5SP1
2649
// 3.5 stripped ".resources", 3.5 SP1 does not. We should do 3.5SP1 thing
2750
letextensionToWorkaround=".resources"
28-
if embeddedFileName.EndsWith(extensionToWorkaround, StringComparison.OrdinalIgnoreCase)
51+
letfSharpResult=
52+
if embeddedFileName.EndsWith(extensionToWorkaround, StringComparison.OrdinalIgnoreCase)
2953
&&not(cSharpResult.EndsWith(extensionToWorkaround, StringComparison.OrdinalIgnoreCase))then
3054
cSharpResult+ extensionToWorkaround
31-
else
55+
else
3256
cSharpResult
57+
58+
printfn"fSharpResult = '%s'" fSharpResult
59+
fSharpResult
3360

3461

3562
overridethis.IsSourceFile(filename:string)=

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp