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

Commit176d669

Browse files
authored
issue# 4591 - Resx files are not working for fsharp project (dotnet#4595)
1 parent92e6d6a commit176d669

File tree

4 files changed

+112
-25
lines changed

4 files changed

+112
-25
lines changed

‎build-everything.proj‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161

6262
<!-- +++++++++++++++++++++++ Project selection for testing +++++++++++++++++++++++++++++++-->
6363

64-
<ItemGroupCondition="'$(TEST_NET40_COREUNIT_SUITE)'=='1'" >
64+
<ItemGroupCondition="'$(TEST_NET40_COMPILERUNIT_SUITE)'=='1'" >
6565
<ProjectsWithNet40Include="tests/FSharp.Core.UnitTests/FSharp.Core.Unittests.fsproj"/>
6666
<ProjectsWithNet40Include="tests/FSharp.Build.UnitTests/FSharp.Build.UnitTests.fsproj"/>
6767
</ItemGroup>

‎build.cmd‎

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ echo SNEXE32: %SNEXE32%
841841
echo SNEXE64:%SNEXE64%
842842
echo
843843

844-
if"%TEST_NET40_COMPILERUNIT_SUITE%"=="0"if"%TEST_FCS%"=="0"if"%TEST_NET40_COREUNIT_SUITE%"=="0"if"%TEST_CORECLR_COREUNIT_SUITE%"=="0"if"%TEST_VS_IDEUNIT_SUITE%"=="0"if"%TEST_NET40_FSHARP_SUITE%"=="0"if"%TEST_NET40_FSHARPQA_SUITE%"=="0"goto :success
844+
if"%TEST_NET40_COMPILERUNIT_SUITE%"=="0"if"%TEST_FCS%"=="0"if"%TEST_NET40_COREUNIT_SUITE%"=="0"if"TEST_CORECLR_FSHARP_SUITE"=="0"if"%TEST_CORECLR_COREUNIT_SUITE%"=="0"if"%TEST_VS_IDEUNIT_SUITE%"=="0"if"%TEST_NET40_FSHARP_SUITE%"=="0"if"%TEST_NET40_FSHARPQA_SUITE%"=="0"goto :success
845845

846846
if"%no_test%"=="1"goto :success
847847

@@ -996,38 +996,49 @@ if "%TEST_NET40_COMPILERUNIT_SUITE%" == "1" (
996996
echo -----------------------------------------------------------------
997997
goto :failure
998998
)
999-
)
1000-
1001-
REM ---------------- net40-coreunit -----------------------
1002-
1003-
if"%TEST_NET40_COREUNIT_SUITE%"=="1" (
1004999

10051000
setOUTPUTARG=
10061001
setERRORARG=
10071002
setOUTPUTFILE=
10081003
setERRORFILE=
1009-
setXMLFILE=!RESULTSDIR!\test-net40-coreunit-results.xml
1004+
setXMLFILE=!RESULTSDIR!\test-net40-buildunit-results.xml
10101005
if"%CI%"=="1" (
1011-
setERRORFILE=!RESULTSDIR!\test-net40-coreunit-errors.log
1012-
setOUTPUTFILE=!RESULTSDIR!\test-net40-coreunit-output.log
1006+
setOUTPUTFILE=!RESULTSDIR!\test-net40-buildunit-output.log
1007+
setERRORFILE=!RESULTSDIR!\test-net40-buildunit-errors.log
10131008
setERRORARG=--err:"!ERRORFILE!"
10141009
setOUTPUTARG=--output:"!OUTPUTFILE!"
10151010
)
1016-
1011+
setERRORFILE=!RESULTSDIR!\test-net40-buildunit-errors.log
10171012
echo"!NUNIT3_CONSOLE!" --verbose --framework:V4.0 --result:"!XMLFILE!;format=nunit3"!OUTPUTARG!!ERRORARG! --work:"!FSCBINPATH!""!FSCBINPATH!\FSharp.Build.UnitTests.dll"!WHERE_ARG_NUNIT!
10181013
"!NUNIT3_CONSOLE!" --verbose --framework:V4.0 --result:"!XMLFILE!;format=nunit3"!OUTPUTARG!!ERRORARG! --work:"!FSCBINPATH!""!FSCBINPATH!\FSharp.Build.UnitTests.dll"!WHERE_ARG_NUNIT!
10191014

1020-
10211015
iferrorlevel1 (
10221016
echo -----------------------------------------------------------------
10231017
type"!OUTPUTFILE!"
10241018
echo -----------------------------------------------------------------
10251019
type"!ERRORFILE!"
10261020
echo -----------------------------------------------------------------
1027-
echo Error: Running tests net40-coreunit failed, see logs above -- FAILED
1021+
echo Error: Running tests net40-compilernit failed, see logs above -- FAILED
10281022
echo -----------------------------------------------------------------
10291023
goto :failure
10301024
)
1025+
)
1026+
1027+
REM ---------------- net40-coreunit -----------------------
1028+
1029+
if"%TEST_NET40_COREUNIT_SUITE%"=="1" (
1030+
1031+
setOUTPUTARG=
1032+
setERRORARG=
1033+
setOUTPUTFILE=
1034+
setERRORFILE=
1035+
setXMLFILE=!RESULTSDIR!\test-net40-coreunit-results.xml
1036+
if"%CI%"=="1" (
1037+
setERRORFILE=!RESULTSDIR!\test-net40-coreunit-errors.log
1038+
setOUTPUTFILE=!RESULTSDIR!\test-net40-coreunit-output.log
1039+
setERRORARG=--err:"!ERRORFILE!"
1040+
setOUTPUTARG=--output:"!OUTPUTFILE!"
1041+
)
10311042

10321043
echo"!NUNIT3_CONSOLE!" --verbose --framework:V4.0 --result:"!XMLFILE!;format=nunit3"!OUTPUTARG!!ERRORARG! --work:"!FSCBINPATH!""!FSCBINPATH!\FSharp.Core.UnitTests.dll"!WHERE_ARG_NUNIT!
10331044
"!NUNIT3_CONSOLE!" --verbose --framework:V4.0 --result:"!XMLFILE!;format=nunit3"!OUTPUTARG!!ERRORARG! --work:"!FSCBINPATH!""!FSCBINPATH!\FSharp.Core.UnitTests.dll"!WHERE_ARG_NUNIT!

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

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ type WriteCodeFragment() =
3333
|_-> sb.Append(c))(StringBuilder().Append("\""))
3434
sb.Append("\"").ToString()
3535

36-
static memberGenerateAttribute(item:ITaskItem)=
36+
static memberGenerateAttribute(item:ITaskItem,language:string)=
3737
letattributeName= item.ItemSpec
3838
letargs=
3939
// mimicking the behavior from https://github.com/Microsoft/msbuild/blob/70ce7e9ccb891b63f0859f1f7f0b955693ed3742/src/Tasks/WriteCodeFragment.cs#L355-L415
@@ -73,7 +73,11 @@ type WriteCodeFragment() =
7373
|(0,_)-> combinedNamedParameters// only named arguments
7474
|(_,0)-> combinedOrderedParameters// only positional arguments
7575
|(_,_)-> combinedOrderedParameters+","+ combinedNamedParameters// both positional and named arguments
76-
sprintf"[<assembly:%s(%s)>]" attributeName args
76+
match language.ToLowerInvariant()with
77+
|"f#"-> sprintf"[<assembly:%s(%s)>]" attributeName args
78+
|"c#"-> sprintf"[assembly:%s(%s)]" attributeName args
79+
|"vb"-> sprintf"<Assembly:%s(%s)>" attributeName args
80+
|_-> failwith"Language name must be one of F#, C# or VB"
7781

7882
// adding this property to maintain API equivalence with the MSBuild task
7983
memberthis.Language
@@ -93,27 +97,32 @@ type WriteCodeFragment() =
9397
with get()=_outputFile
9498
andset(value)=_outputFile<- value
9599

100+
96101
interface ITaskwith
97102
memberthis.BuildEngine
98103
with get()=_buildEngine
99104
andset(value)=_buildEngine<- value
105+
100106
memberthis.HostObject
101107
with get()=_hostObject
102108
andset(value)=_hostObject<- value
109+
103110
memberthis.Execute()=
104111
try
105112
if isNull_outputFile&& isNull_outputDirectorythen failwith"Output location must be specified"
106-
if_language.ToLowerInvariant()<>"f#"then failwith"Language name must be F#"
107-
letboilerplate=@"// <auto-generated>
113+
letboilerplate=
114+
match_language.ToLowerInvariant()with
115+
|"f#"->"// <auto-generated>\n// Generated by the FSharp WriteCodeFragment class.\n// </auto-generated>\nnamespace FSharp\n\nopen System\nopen System.Reflection\n"
116+
|"c#"->"// <auto-generated>\n// Generated by the FSharp WriteCodeFragment class.\n// </auto-generated>\n\nusing System;\nusing System.Reflection;"
117+
|"vb"->"'------------------------------------------------------------------------------\n' <auto-generated>\n' Generated by the FSharp WriteCodeFragment class.\n' </auto-generated>\n'------------------------------------------------------------------------------\n\nOption Strict Off\nOption Explicit On\n\nImports System\nImports System.Reflection"
118+
|_-> failwith"Language name must be one of F#, C# or VB"
108119

109-
namespace FSharp
110-
111-
open System
112-
open System.Reflection"
113120
letsb= StringBuilder().AppendLine(boilerplate).AppendLine()
114-
letcode= Array.fold(fun(sb:StringBuilder)(item:ITaskItem)-> sb.AppendLine(WriteCodeFragment.GenerateAttribute item)) sb_assemblyAttributes
115-
code.AppendLine().AppendLine("do()")|> ignore
121+
letcode= Array.fold(fun(sb:StringBuilder)(item:ITaskItem)-> sb.AppendLine(WriteCodeFragment.GenerateAttribute(item,_language.ToLowerInvariant()))) sb_assemblyAttributes
122+
123+
if_language.ToLowerInvariant()="f#"then code.AppendLine("do()")|> ignore
116124
letfileName=_outputFile.ItemSpec
125+
117126
letoutputFileItem=
118127
ifnot(isNull_outputFile)&&not(isNull_outputDirectory)&&not(Path.IsPathRooted(fileName))then
119128
TaskItem(Path.Combine(_outputDirectory.ItemSpec, fileName)):> ITaskItem
@@ -122,12 +131,14 @@ open System.Reflection"
122131
TaskItem(tempFile):> ITaskItem
123132
else
124133
_outputFile
134+
125135
letcodeText= code.ToString()
126136
letalreadyExists=(try File.Exists fileName&& File.ReadAllText(fileName)= codeTextwith_->false)
127137
ifnot alreadyExiststhen
128138
File.WriteAllText(fileName, codeText)
129139
_outputFile<- outputFileItem
130140
true
141+
131142
with e->
132143
printf"Error writing code fragment:%s"(e.ToString())
133144
false

‎tests/FSharp.Build.UnitTests/WriteCodeFragmentTests.fs‎

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ open Microsoft.FSharp.Build
88
openNUnit.Framework
99

1010
[<TestFixture>]
11-
typeWriteCodeFragmentTests()=
11+
typeWriteCodeFragmentFSharpTests()=
1212

1313
letverifyAttribute(attributeName:string)(parameters:(string*string)list)(expectedAttributeText:string)=
1414
lettaskItem= TaskItem(attributeName)
1515
parameters|> List.iter(fun(key,value)-> taskItem.SetMetadata(key, value))
16-
letactualAttributeText= WriteCodeFragment.GenerateAttribute(taskItem:> ITaskItem)
16+
letactualAttributeText= WriteCodeFragment.GenerateAttribute(taskItem:> ITaskItem,"f#")
1717
letfullExpectedAttributeText="[<assembly:"+ expectedAttributeText+">]"
1818
Assert.AreEqual(fullExpectedAttributeText, actualAttributeText)
1919

@@ -37,3 +37,68 @@ type WriteCodeFragmentTests()=
3737
memberthis.``Escaped string parameters``()=
3838
verifyAttribute"SomeAttribute"[("_Parameter1","\"uno\"")]"SomeAttribute(\"\\\"uno\\\"\")"
3939
// this should look like: SomeAttribute("\"uno\"")
40+
41+
42+
[<TestFixture>]
43+
typeWriteCodeFragmentCSharpTests()=
44+
45+
letverifyAttribute(attributeName:string)(parameters:(string*string)list)(expectedAttributeText:string)=
46+
lettaskItem= TaskItem(attributeName)
47+
parameters|> List.iter(fun(key,value)-> taskItem.SetMetadata(key, value))
48+
letactualAttributeText= WriteCodeFragment.GenerateAttribute(taskItem:> ITaskItem,"c#")
49+
letfullExpectedAttributeText="[assembly:"+ expectedAttributeText+"]"
50+
Assert.AreEqual(fullExpectedAttributeText, actualAttributeText)
51+
52+
[<Test>]
53+
memberthis.``No parameters``()=
54+
verifyAttribute"SomeAttribute"[]"SomeAttribute()"
55+
56+
[<Test>]
57+
memberthis.``Skipped and out of order positional parameters``()=
58+
verifyAttribute"SomeAttribute"[("_Parameter3","3");("_Parameter5","5");("_Parameter2","2")]"SomeAttribute(null,\"2\",\"3\", null,\"5\")"
59+
60+
[<Test>]
61+
memberthis.``Named parameters``()=
62+
verifyAttribute"SomeAttribute"[("One","1");("Two","2")]"SomeAttribute(One =\"1\", Two =\"2\")"
63+
64+
[<Test>]
65+
memberthis.``Named and positional parameters``()=
66+
verifyAttribute"SomeAttribute"[("One","1");("_Parameter2","2.2");("Two","2")]"SomeAttribute(null,\"2.2\", One =\"1\", Two =\"2\")"
67+
68+
[<Test>]
69+
memberthis.``Escaped string parameters``()=
70+
verifyAttribute"SomeAttribute"[("_Parameter1","\"uno\"")]"SomeAttribute(\"\\\"uno\\\"\")"
71+
// this should look like: SomeAttribute("\"uno\"")
72+
73+
74+
[<TestFixture>]
75+
typeWriteCodeFragmentVisualBasicTests()=
76+
77+
letverifyAttribute(attributeName:string)(parameters:(string*string)list)(expectedAttributeText:string)=
78+
lettaskItem= TaskItem(attributeName)
79+
parameters|> List.iter(fun(key,value)-> taskItem.SetMetadata(key, value))
80+
letactualAttributeText= WriteCodeFragment.GenerateAttribute(taskItem:> ITaskItem,"vb")
81+
letfullExpectedAttributeText="<Assembly:"+ expectedAttributeText+">"
82+
Assert.AreEqual(fullExpectedAttributeText, actualAttributeText)
83+
84+
[<Test>]
85+
memberthis.``No parameters``()=
86+
verifyAttribute"SomeAttribute"[]"SomeAttribute()"
87+
88+
[<Test>]
89+
memberthis.``Skipped and out of order positional parameters``()=
90+
verifyAttribute"SomeAttribute"[("_Parameter3","3");("_Parameter5","5");("_Parameter2","2")]"SomeAttribute(null,\"2\",\"3\", null,\"5\")"
91+
92+
[<Test>]
93+
memberthis.``Named parameters``()=
94+
verifyAttribute"SomeAttribute"[("One","1");("Two","2")]"SomeAttribute(One =\"1\", Two =\"2\")"
95+
96+
[<Test>]
97+
memberthis.``Named and positional parameters``()=
98+
verifyAttribute"SomeAttribute"[("One","1");("_Parameter2","2.2");("Two","2")]"SomeAttribute(null,\"2.2\", One =\"1\", Two =\"2\")"
99+
100+
[<Test>]
101+
memberthis.``Escaped string parameters``()=
102+
verifyAttribute"SomeAttribute"[("_Parameter1","\"uno\"")]"SomeAttribute(\"\\\"uno\\\"\")"
103+
// this should look like: SomeAttribute("\"uno\"")
104+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp