Skip to content

Commit 9d29b79

Browse files
authored
Merge pull request #8131 from dotnet/merges/master-to-release/dev16.5
Merge master to release/dev16.5
2 parents fd8da61 + 69a2525 commit 9d29b79

26 files changed

+339
-119
lines changed

FSharpBuild.Directory.Build.targets

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<PropertyGroup>
1515
<__TargetFilePath>@(NoneSubstituteText->'$(IntermediateOutputPath)%(Filename)%(Extension)')</__TargetFilePath>
1616
<__TargetFileName>@(NoneSubstituteText->'%(Filename)%(Extension)')</__TargetFileName>
17+
<__TargetLink>@(NoneSubstituteText->'%(Link)')</__TargetLink>
1718

1819
<_ReplacementText>$([System.IO.File]::ReadAllText('%(NoneSubstituteText.FullPath)'))</_ReplacementText>
1920
<_ReplacementText Condition="'%(NoneSubstituteText.Pattern1)' != ''">$(_ReplacementText.Replace('%(NoneSubstituteText.Pattern1)', '%(NoneSubstituteText.Replacement1)'))</_ReplacementText>
@@ -33,7 +34,7 @@
3334
<ItemGroup>
3435
<None Include="$(__TargetFilePath)" CopyToOutputDirectory="$(_CopyToOutputDirectory)" />
3536
<FileWrites Include="$(__TargetFilePath)" Condition="'$(__TargetFileName)' != 'App.config'" />
36-
<Content Include="$(__TargetFilePath)" CopyToOutputDirectory="Always" IncludeInVsix="true" />
37+
<Content Include="$(__TargetFilePath)" CopyToOutputDirectory="Always" IncludeInVsix="true" Link="$(__TargetLink)" Condition="'$(_IncludeInVsix)'=='true'" />
3738
</ItemGroup>
3839
</Target>
3940

src/fsharp/ConstraintSolver.fs

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -835,10 +835,35 @@ and SolveAnonInfoEqualsAnonInfo (csenv: ConstraintSolverEnv) m2 (anonInfo1: Anon
835835
(match anonInfo1.Assembly, anonInfo2.Assembly with
836836
| ccu1, ccu2 -> if not (ccuEq ccu1 ccu2) then ErrorD (ConstraintSolverError(FSComp.SR.tcAnonRecdCcuMismatch(ccu1.AssemblyName, ccu2.AssemblyName), csenv.m,m2)) else ResultD ()
837837
) ++ (fun () ->
838+
838839
if not (anonInfo1.SortedNames = anonInfo2.SortedNames) then
839-
let namesText1 = sprintf "%A" (Array.toList anonInfo1.SortedNames)
840-
let namesText2 = sprintf "%A" (Array.toList anonInfo2.SortedNames)
841-
ErrorD (ConstraintSolverError(FSComp.SR.tcAnonRecdFieldNameMismatch(namesText1, namesText2), csenv.m,m2))
840+
let (|Subset|Superset|Overlap|CompletelyDifferent|) (first, second) =
841+
let first = Set first
842+
let second = Set second
843+
let secondOnly = Set.toList (second - first)
844+
let firstOnly = Set.toList (first - second)
845+
846+
if second.IsSubsetOf first then
847+
Subset firstOnly
848+
elif second.IsSupersetOf first then
849+
Superset secondOnly
850+
elif Set.intersect first second <> Set.empty then
851+
Overlap(firstOnly, secondOnly)
852+
else
853+
CompletelyDifferent(Seq.toList first)
854+
855+
let message =
856+
match anonInfo1.SortedNames, anonInfo2.SortedNames with
857+
| Subset missingFields ->
858+
FSComp.SR.tcAnonRecdFieldNameSubset(string missingFields)
859+
| Superset extraFields ->
860+
FSComp.SR.tcAnonRecdFieldNameSuperset(string extraFields)
861+
| Overlap (missingFields, extraFields) ->
862+
FSComp.SR.tcAnonRecdFieldNameMismatch(string missingFields, string extraFields)
863+
| CompletelyDifferent missingFields ->
864+
FSComp.SR.tcAnonRecdFieldNameDifferent(string missingFields)
865+
866+
ErrorD (ConstraintSolverError(message, csenv.m,m2))
842867
else
843868
ResultD ())
844869

src/fsharp/FSComp.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1352,7 +1352,10 @@ tcGlobalsSystemTypeNotFound,"The system type '%s' was required but no referenced
13521352
3214,methodIsNotStatic,"Method or object constructor '%s' is not static"
13531353
3215,parsUnexpectedSymbolEqualsInsteadOfIn,"Unexpected symbol '=' in expression. Did you intend to use 'for x in y .. z do' instead?"
13541354
tcAnonRecdCcuMismatch,"Two anonymous record types are from different assemblies '%s' and '%s'"
1355-
tcAnonRecdFieldNameMismatch,"Two anonymous record types have mismatched sets of field names '%s' and '%s'"
1355+
tcAnonRecdFieldNameMismatch,"This anonymous record does not exactly match the expected shape. Add the missing fields %s and remove the extra fields %s."
1356+
tcAnonRecdFieldNameSubset,"This anonymous record does not have enough fields. Add the missing fields %s."
1357+
tcAnonRecdFieldNameSuperset,"This anonymous record has too many fields. Remove the extra fields %s."
1358+
tcAnonRecdFieldNameDifferent,"This is the wrong anonymous record. It should have the fields %s."
13561359
keywordDescriptionAbstract,"Indicates a method that either has no implementation in the type in which it is declared or that is virtual and has a default implementation."
13571360
keyworkDescriptionAnd,"Used in mutually recursive bindings, in property declarations, and with multiple constraints on generic parameters."
13581361
keywordDescriptionAs,"Used to give the current class object an object name. Also used to give a name to a whole pattern within a pattern match."

src/fsharp/FSharp.Compiler.Private.Scripting/FSharp.Compiler.Private.Scripting.fsproj

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<Compile Include="TextHelpers.fs" />
1312
<Compile Include="FSharpScript.fs" />
1413
</ItemGroup>
1514

1615
<ItemGroup>
17-
<NuspecProperty Include="FSharpCoreVersion=$(FSCorePackageVersion)-$(VersionSuffix)"/>
18-
<NuspecProperty Include="TargetFramework=$(TargetFramework)"/>
16+
<NuspecProperty Include="FSharpCoreVersion=$(FSCorePackageVersion)-$(VersionSuffix)" />
17+
<NuspecProperty Include="TargetFramework=$(TargetFramework)" />
1918
</ItemGroup>
2019

2120
<ItemGroup>

src/fsharp/FSharp.Compiler.Private.Scripting/FSharpScript.fs

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -7,49 +7,22 @@ open System.Threading
77
open FSharp.Compiler
88
open FSharp.Compiler.Interactive.Shell
99

10-
type FSharpScript(?captureInput: bool, ?captureOutput: bool, ?additionalArgs: string[]) as this =
11-
let outputProduced = Event<string>()
12-
let errorProduced = Event<string>()
10+
type FSharpScript(?additionalArgs: string[]) =
1311

14-
// handle stdin/stdout
15-
let stdin = new CapturedTextReader()
16-
let stdout = new EventedTextWriter()
17-
let stderr = new EventedTextWriter()
18-
do stdout.LineWritten.Add outputProduced.Trigger
19-
do stderr.LineWritten.Add errorProduced.Trigger
20-
let captureInput = defaultArg captureInput false
21-
let captureOutput = defaultArg captureOutput false
2212
let additionalArgs = defaultArg additionalArgs [||]
23-
let savedInput = Console.In
24-
let savedOutput = Console.Out
25-
let savedError = Console.Error
26-
do (fun () ->
27-
if captureInput then
28-
Console.SetIn(stdin)
29-
if captureOutput then
30-
Console.SetOut(stdout)
31-
Console.SetError(stderr)
32-
())()
33-
3413
let config = FsiEvaluationSession.GetDefaultConfiguration()
3514
let computedProfile =
3615
// If we are being executed on the desktop framework (we can tell because the assembly containing int is mscorlib) then profile must be mscorlib otherwise use netcore
3716
if typeof<int>.Assembly.GetName().Name = "mscorlib" then "mscorlib"
3817
else "netcore"
39-
let baseArgs = [| this.GetType().Assembly.Location; "--noninteractive"; "--targetprofile:" + computedProfile; "--quiet" |]
18+
let baseArgs = [| typeof<FSharpScript>.Assembly.Location; "--noninteractive"; "--targetprofile:" + computedProfile; "--quiet" |]
4019
let argv = Array.append baseArgs additionalArgs
4120
let fsi = FsiEvaluationSession.Create (config, argv, stdin, stdout, stderr, collectible=true)
4221

4322
member __.AssemblyReferenceAdded = fsi.AssemblyReferenceAdded
4423

4524
member __.ValueBound = fsi.ValueBound
4625

47-
member __.ProvideInput = stdin.ProvideInput
48-
49-
member __.OutputProduced = outputProduced.Publish
50-
51-
member __.ErrorProduced = errorProduced.Publish
52-
5326
member __.Fsi = fsi
5427

5528
member __.Eval(code: string, ?cancellationToken: CancellationToken) =
@@ -75,12 +48,4 @@ type FSharpScript(?captureInput: bool, ?captureOutput: bool, ?additionalArgs: st
7548

7649
interface IDisposable with
7750
member __.Dispose() =
78-
if captureInput then
79-
Console.SetIn(savedInput)
80-
if captureOutput then
81-
Console.SetOut(savedOutput)
82-
Console.SetError(savedError)
83-
stdin.Dispose()
84-
stdout.Dispose()
85-
stderr.Dispose()
8651
(fsi :> IDisposable).Dispose()

src/fsharp/FSharp.Compiler.Private.Scripting/TextHelpers.fs

Lines changed: 0 additions & 36 deletions
This file was deleted.

src/fsharp/xlf/FSComp.txt.cs.xlf

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,21 @@
4747
<target state="translated">Algoritmus {0} není podporovaný.</target>
4848
<note />
4949
</trans-unit>
50+
<trans-unit id="tcAnonRecdFieldNameDifferent">
51+
<source>This is the wrong anonymous record. It should have the fields {0}.</source>
52+
<target state="new">This is the wrong anonymous record. It should have the fields {0}.</target>
53+
<note />
54+
</trans-unit>
55+
<trans-unit id="tcAnonRecdFieldNameSubset">
56+
<source>This anonymous record does not have enough fields. Add the missing fields {0}.</source>
57+
<target state="new">This anonymous record does not have enough fields. Add the missing fields {0}.</target>
58+
<note />
59+
</trans-unit>
60+
<trans-unit id="tcAnonRecdFieldNameSuperset">
61+
<source>This anonymous record has too many fields. Remove the extra fields {0}.</source>
62+
<target state="new">This anonymous record has too many fields. Remove the extra fields {0}.</target>
63+
<note />
64+
</trans-unit>
5065
<trans-unit id="tcAugmentationsCannotHaveAttributes">
5166
<source>Attributes cannot be applied to type extensions.</source>
5267
<target state="translated">Atributy nejde použít pro rozšíření typů.</target>
@@ -7128,8 +7143,8 @@
71287143
<note />
71297144
</trans-unit>
71307145
<trans-unit id="tcAnonRecdFieldNameMismatch">
7131-
<source>Two anonymous record types have mismatched sets of field names '{0}' and '{1}'</source>
7132-
<target state="translated">Dva typy anonymních záznamů mají odlišné sady názvů polí: {0} a {1}</target>
7146+
<source>This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}.</source>
7147+
<target state="needs-review-translation">Dva typy anonymních záznamů mají odlišné sady názvů polí: {0} a {1}</target>
71337148
<note />
71347149
</trans-unit>
71357150
<trans-unit id="tcCannotCallExtensionMethodInrefToByref">

src/fsharp/xlf/FSComp.txt.de.xlf

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,21 @@
4747
<target state="translated">Algorithmus "{0}" wird nicht unterstützt</target>
4848
<note />
4949
</trans-unit>
50+
<trans-unit id="tcAnonRecdFieldNameDifferent">
51+
<source>This is the wrong anonymous record. It should have the fields {0}.</source>
52+
<target state="new">This is the wrong anonymous record. It should have the fields {0}.</target>
53+
<note />
54+
</trans-unit>
55+
<trans-unit id="tcAnonRecdFieldNameSubset">
56+
<source>This anonymous record does not have enough fields. Add the missing fields {0}.</source>
57+
<target state="new">This anonymous record does not have enough fields. Add the missing fields {0}.</target>
58+
<note />
59+
</trans-unit>
60+
<trans-unit id="tcAnonRecdFieldNameSuperset">
61+
<source>This anonymous record has too many fields. Remove the extra fields {0}.</source>
62+
<target state="new">This anonymous record has too many fields. Remove the extra fields {0}.</target>
63+
<note />
64+
</trans-unit>
5065
<trans-unit id="tcAugmentationsCannotHaveAttributes">
5166
<source>Attributes cannot be applied to type extensions.</source>
5267
<target state="translated">Attribute können nicht auf Typerweiterungen angewendet werden.</target>
@@ -7128,8 +7143,8 @@
71287143
<note />
71297144
</trans-unit>
71307145
<trans-unit id="tcAnonRecdFieldNameMismatch">
7131-
<source>Two anonymous record types have mismatched sets of field names '{0}' and '{1}'</source>
7132-
<target state="translated">Zwei anonyme Datensatztypen weisen die nicht übereinstimmenden Feldnamen "{0}" und "{1}" auf.</target>
7146+
<source>This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}.</source>
7147+
<target state="needs-review-translation">Zwei anonyme Datensatztypen weisen die nicht übereinstimmenden Feldnamen "{0}" und "{1}" auf.</target>
71337148
<note />
71347149
</trans-unit>
71357150
<trans-unit id="tcCannotCallExtensionMethodInrefToByref">

src/fsharp/xlf/FSComp.txt.es.xlf

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,21 @@
4747
<target state="translated">No se admite el algoritmo '{0}'</target>
4848
<note />
4949
</trans-unit>
50+
<trans-unit id="tcAnonRecdFieldNameDifferent">
51+
<source>This is the wrong anonymous record. It should have the fields {0}.</source>
52+
<target state="new">This is the wrong anonymous record. It should have the fields {0}.</target>
53+
<note />
54+
</trans-unit>
55+
<trans-unit id="tcAnonRecdFieldNameSubset">
56+
<source>This anonymous record does not have enough fields. Add the missing fields {0}.</source>
57+
<target state="new">This anonymous record does not have enough fields. Add the missing fields {0}.</target>
58+
<note />
59+
</trans-unit>
60+
<trans-unit id="tcAnonRecdFieldNameSuperset">
61+
<source>This anonymous record has too many fields. Remove the extra fields {0}.</source>
62+
<target state="new">This anonymous record has too many fields. Remove the extra fields {0}.</target>
63+
<note />
64+
</trans-unit>
5065
<trans-unit id="tcAugmentationsCannotHaveAttributes">
5166
<source>Attributes cannot be applied to type extensions.</source>
5267
<target state="translated">Los atributos no se pueden aplicar a las extensiones de tipo.</target>
@@ -159,7 +174,7 @@
159174
</trans-unit>
160175
<trans-unit id="followingPatternMatchClauseHasWrongType">
161176
<source>All branches of a pattern match expression must return values of the same type as the first branch, which here is '{0}'. This branch returns a value of type '{1}'.</source>
162-
<target state="translated">Todas las ramas de una expresión de coincidencia de patrón deben devolver valores del mismo tipo. La primera rama devolvió un valor de tipo "{0}", pero esta rama devolvió un valor de tipo "\{1 \}".</target>
177+
<target state="new">All branches of a pattern match expression must return values of the same type as the first branch, which here is '{0}'. This branch returns a value of type '{1}'.</target>
163178
<note />
164179
</trans-unit>
165180
<trans-unit id="patternMatchGuardIsNotBool">
@@ -7128,8 +7143,8 @@
71287143
<note />
71297144
</trans-unit>
71307145
<trans-unit id="tcAnonRecdFieldNameMismatch">
7131-
<source>Two anonymous record types have mismatched sets of field names '{0}' and '{1}'</source>
7132-
<target state="translated">Dos tipos de registros anónimos tienen conjuntos de nombres de campo que no coinciden "{0}" y "{1}"</target>
7146+
<source>This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}.</source>
7147+
<target state="needs-review-translation">Dos tipos de registros anónimos tienen conjuntos de nombres de campo que no coinciden "{0}" y "{1}"</target>
71337148
<note />
71347149
</trans-unit>
71357150
<trans-unit id="tcCannotCallExtensionMethodInrefToByref">

src/fsharp/xlf/FSComp.txt.fr.xlf

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,21 @@
4747
<target state="translated">Algorithme '{0}' non pris en charge</target>
4848
<note />
4949
</trans-unit>
50+
<trans-unit id="tcAnonRecdFieldNameDifferent">
51+
<source>This is the wrong anonymous record. It should have the fields {0}.</source>
52+
<target state="new">This is the wrong anonymous record. It should have the fields {0}.</target>
53+
<note />
54+
</trans-unit>
55+
<trans-unit id="tcAnonRecdFieldNameSubset">
56+
<source>This anonymous record does not have enough fields. Add the missing fields {0}.</source>
57+
<target state="new">This anonymous record does not have enough fields. Add the missing fields {0}.</target>
58+
<note />
59+
</trans-unit>
60+
<trans-unit id="tcAnonRecdFieldNameSuperset">
61+
<source>This anonymous record has too many fields. Remove the extra fields {0}.</source>
62+
<target state="new">This anonymous record has too many fields. Remove the extra fields {0}.</target>
63+
<note />
64+
</trans-unit>
5065
<trans-unit id="tcAugmentationsCannotHaveAttributes">
5166
<source>Attributes cannot be applied to type extensions.</source>
5267
<target state="translated">Impossible d'appliquer des attributs aux extensions de type.</target>
@@ -7128,8 +7143,8 @@
71287143
<note />
71297144
</trans-unit>
71307145
<trans-unit id="tcAnonRecdFieldNameMismatch">
7131-
<source>Two anonymous record types have mismatched sets of field names '{0}' and '{1}'</source>
7132-
<target state="translated">Deux types d'enregistrement anonyme ont des ensembles de noms de champ incompatibles '{0}' et '{1}'</target>
7146+
<source>This anonymous record does not exactly match the expected shape. Add the missing fields {0} and remove the extra fields {1}.</source>
7147+
<target state="needs-review-translation">Deux types d'enregistrement anonyme ont des ensembles de noms de champ incompatibles '{0}' et '{1}'</target>
71337148
<note />
71347149
</trans-unit>
71357150
<trans-unit id="tcCannotCallExtensionMethodInrefToByref">

0 commit comments

Comments
 (0)