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

Commitcccf5b9

Browse files
dsymelatkin
authored andcommitted
Fix 316 - correctly handle null array values in attributes
fixesdotnet#316closesdotnet#433commit6d9584cAuthor: Don Syme <donsyme@fastmail.fm>Date: Sat May 9 18:14:42 2015 +0100 fix 316commitda56716Author: Don Syme <donsyme@fastmail.fm>Date: Sat May 9 17:45:54 2015 +0100 Fix 316
1 parent92a064b commitcccf5b9

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

‎src/absil/il.fs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4388,6 +4388,8 @@ and encodeCustomAttrValue ilg ty c =
43884388
match ty, cwith
43894389
| ILType.Boxed tspec,_when tspec.Name= tname_Object->
43904390
[|yield! encodeCustomAttrElemTypeForObject c;yield! encodeCustomAttrPrimValue ilg c|]
4391+
| ILType.Array(shape,_), ILAttribElem.Nullwhen shape= ILArrayShape.SingleDimensional->
4392+
[|yield! i32AsBytes0xFFFFFFFF|]
43914393
| ILType.Array(shape, elemType), ILAttribElem.Array(_,elems)when shape= ILArrayShape.SingleDimensional->
43924394
[|yield! i32AsBytes elems.Length;for elemin elemsdoyield! encodeCustomAttrValue ilg elemType elem|]
43934395
|_->
@@ -4755,6 +4757,7 @@ let decodeILAttribData ilg (ca: ILAttribute) scope =
47554757
parseVal ty sigptr
47564758
| ILType.Array(shape,elemTy)when shape= ILArrayShape.SingleDimensional->
47574759
letn,sigptr= sigptr_get_i32 bytes sigptr
4760+
if n=0xFFFFFFFFthen ILAttribElem.Null,sigptrelse
47584761
let recparseElems acc n sigptr=
47594762
if n=0then List.rev accelse
47604763
letv,sigptr= parseVal elemTy sigptr

‎src/fsharp/ilxgen.fs‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5682,7 +5682,11 @@ and GenAttribArg amap g eenv x (ilArgTy:ILType) =
56825682

56835683
match x,ilArgTywith
56845684

5685-
(* Detect standard constants*)
5685+
// Detect 'null' used for an array argument
5686+
| Expr.Const(Const.Zero,_,_),ILType.Array_->
5687+
ILAttribElem.Null
5688+
5689+
// Detect standard constants
56865690
| Expr.Const(c,m,_),_->
56875691
lettynm= ilArgTy.TypeSpec.Name
56885692
letisobj=(tynm="System.Object")

‎tests/fsharp/core/attributes/test.fsx‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,6 +1299,28 @@ module AttributeTestsOnExtensionProperties =
12991299
check"vwlnwer-0wreknj4"(test3())"Equals: [||], GetHashCode: [||], GetType: [||], Object.get_ExtensionMethod: [|Inline|], Object.get_Item: [|Inline|], Object.set_Item: [|Inline|], ToString: [||]"
13001300

13011301

1302+
moduleParamArrayNullAttribute=
1303+
openSystem
1304+
1305+
typeAttr([<ParamArray>]pms: obj[])=
1306+
inherit Attribute()
1307+
overridex.ToString()= sprintf"Attr(%A)" pms
1308+
1309+
[<Attr(null)>]
1310+
letf()=()
1311+
1312+
lettest3()=
1313+
match<@ f()@>with
1314+
| Quotations.Patterns.Call(_, m,_)->
1315+
m.GetCustomAttributes(typeof<Attr>,false)
1316+
|> Seq.map(fun x-> x.ToString())
1317+
|> String.concat","
1318+
|_-> failwith"unreachable 3"
1319+
1320+
check"vwcewecioj9"(test3())"Attr(<null>)"
1321+
1322+
1323+
13021324
(*-------------------------------------------------------------------------
13031325
!* Test passed?
13041326
*-------------------------------------------------------------------------*)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp