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

Commit44ef814

Browse files
dsymeKevinRansom
authored andcommitted
Fix 4240 - MakeTuple on struct tuples (dotnet#4387)
* Fix 4240 - MakeTuple on struct tuples* fix this mistake
1 parent2c3cfbf commit44ef814

File tree

3 files changed

+549
-311
lines changed

3 files changed

+549
-311
lines changed

‎src/fsharp/FSharp.Core/reflect.fs‎

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -484,44 +484,42 @@ module internal Impl =
484484
#endif
485485
fields
486486

487-
letgetTupleConstructorMethod(typ:Type,bindingFlags)=
487+
letgetTupleConstructorMethod(typ:Type)=
488488
letctor=
489489
if typ.IsValueTypethen
490-
letfields= typ.GetFields(bindingFlags)|> orderTupleFields
490+
letfields= typ.GetFields(instanceFieldFlags||| BindingFlags.Public)|> orderTupleFields
491491
#if FX_RESHAPED_REFLECTION
492-
ignore bindingFlags
493492
typ.GetConstructor(fields|> Array.map(fun fi-> fi.FieldType))
494493
#else
495-
typ.GetConstructor(BindingFlags.Instance|||bindingFlags,null,fields|> Array.map(fun fi-> fi.FieldType),null)
494+
typ.GetConstructor(BindingFlags.Public|||BindingFlags.Instance,null,fields|> Array.map(fun fi-> fi.FieldType),null)
496495
#endif
497496
else
498497
letprops= typ.GetProperties()|> orderTupleProperties
499498
#if FX_RESHAPED_REFLECTION
500-
ignore bindingFlags
501499
typ.GetConstructor(props|> Array.map(fun p-> p.PropertyType))
502500
#else
503-
typ.GetConstructor(BindingFlags.Instance|||bindingFlags,null,props|> Array.map(fun p-> p.PropertyType),null)
501+
typ.GetConstructor(BindingFlags.Public|||BindingFlags.Instance,null,props|> Array.map(fun p-> p.PropertyType),null)
504502
#endif
505503
match ctorwith
506504
|null-> raise<| ArgumentException(String.Format(SR.GetString(SR.invalidTupleTypeConstructorNotDefined), typ.FullName))
507505
|_->()
508506
ctor
509507

510-
letgetTupleCtor(typ:Type,bindingFlags)=
511-
letctor= getTupleConstructorMethod(typ,bindingFlags)
508+
letgetTupleCtor(typ:Type)=
509+
letctor= getTupleConstructorMethodtyp
512510
(fun(args:obj[])->
513511
#if FX_RESHAPED_REFLECTION
514512
ctor.Invoke(args))
515513
#else
516-
ctor.Invoke(BindingFlags.InvokeMethod||| BindingFlags.Instance|||bindingFlags,null,args,null))
514+
ctor.Invoke(BindingFlags.InvokeMethod||| BindingFlags.Instance|||BindingFlags.Public,null,args,null))
517515
#endif
518516

519517
let recgetTupleReader(typ:Type)=
520518
letetys= typ.GetGenericArguments()
521519
// Get the reader for the outer tuple record
522520
letreader=
523521
if typ.IsValueTypethen
524-
letfields=(typ.GetFields(instanceFieldFlags||| BindingFlags.Public)|> orderTupleFields)
522+
letfields=(typ.GetFields(instanceFieldFlags||| BindingFlags.Public)|> orderTupleFields)
525523
((fun(obj:obj)-> fields|> Array.map(fun field-> field.GetValue(obj))))
526524
else
527525
letprops=(typ.GetProperties(instancePropertyFlags||| BindingFlags.Public)|> orderTupleProperties)
@@ -538,7 +536,7 @@ module internal Impl =
538536

539537
let recgetTupleConstructor(typ:Type)=
540538
letetys= typ.GetGenericArguments()
541-
letmaker1= getTupleCtor(typ,BindingFlags.Public)
539+
letmaker1= getTupleCtor typ
542540
if etys.Length< maxTuple
543541
then maker1
544542
else
@@ -550,7 +548,7 @@ module internal Impl =
550548

551549
letgetTupleConstructorInfo(typ:Type)=
552550
letetys= typ.GetGenericArguments()
553-
letmaker1= getTupleConstructorMethod(typ,BindingFlags.Public)
551+
letmaker1= getTupleConstructorMethod typ
554552
if etys.Length< maxTuplethen
555553
maker1,None
556554
else

‎tests/FSharp.Core.UnitTests/FSharp.Core.Unittests.fsproj‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
<HintPathCondition="'$(TargetDotnetProfile)' == 'net40'">$(FsCheckLibDir)\net45\FsCheck.dll</HintPath>
5353
</Reference>
5454
<ReferenceInclude="System.ValueTuple">
55-
<HintPath>..\..\..\packages\System.ValueTuple.4.3.1\lib\portable-net40+sl4+win8+wp8\System.ValueTuple.dll</HintPath>
55+
<HintPath>..\..\packages\System.ValueTuple.4.3.1\lib\portable-net40+sl4+win8+wp8\System.ValueTuple.dll</HintPath>
5656
<Private>True</Private>
5757
</Reference>
5858
</ItemGroup>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp