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

Commit388d8d9

Browse files
author
dotnet-automerge-bot
authored
Merge pull requestdotnet#5780 from Microsoft/merges/master-to-dev16.0
Merge master to dev16.0
2 parentsde26777 +f5d8131 commit388d8d9

File tree

51 files changed

+792
-268
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+792
-268
lines changed

‎build.cmd‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -633,8 +633,7 @@ goto :eof
633633
:havemsbuild
634634
set_nrswitch=/nr:false
635635

636-
setmsbuildflags=%_nrswitch% /nologo
637-
REM set msbuildflags=%_nrswitch% /nologo
636+
setmsbuildflags=%_nrswitch% /nologo /clp:Summary /v:minimal
638637
set_ngenexe="%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\ngen.exe"
639638
ifnotexist%_ngenexe%echo Error: Could not find ngen.exe.&&goto :failure
640639

‎src/absil/il.fs‎

Lines changed: 47 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -946,11 +946,25 @@ type ILAttribElem =
946946

947947
typeILAttributeNamedArg=(string* ILType* bool* ILAttribElem)
948948

949-
[<StructuralEquality; StructuralComparison; StructuredFormatDisplay("{DebugText}")>]
950-
typeILAttribute=
951-
{ Method:ILMethodSpec
952-
Data:byte[]
953-
Elements:ILAttribElem list}
949+
[<RequireQualifiedAccess; StructuralEquality; StructuralComparison; StructuredFormatDisplay("{DebugText}")>]
950+
typeILAttribute=
951+
| Encodedofmethod:ILMethodSpec*data:byte[]*elements:ILAttribElemlist
952+
| Decodedofmethod:ILMethodSpec*fixedArgs:ILAttribElemlist*namedArgs:ILAttributeNamedArglist
953+
954+
memberx.Method=
955+
match xwith
956+
| Encoded(method,_,_)
957+
| Decoded(method,_,_)-> method
958+
959+
memberx.Elements=
960+
match xwith
961+
| Encoded(_,_, elements)-> elements
962+
| Decoded(_, fixedArgs, namedArgs)-> fixedArgs@(namedArgs|> List.map(fun(_,_,_,e)-> e))
963+
964+
memberx.WithMethod(method:ILMethodSpec)=
965+
match xwith
966+
| Encoded(_, data, elements)-> Encoded(method, data, elements)
967+
| Decoded(_, fixedArgs, namedArgs)-> Decoded(method, fixedArgs, namedArgs)
954968

955969
/// For debugging
956970
[<DebuggerBrowsable(DebuggerBrowsableState.Never)>]
@@ -3571,21 +3585,30 @@ let encodeCustomAttrNamedArg ilg (nm, ty, prop, elem) =
35713585
yield! encodeCustomAttrString nm
35723586
yield! encodeCustomAttrValue ilg ty elem|]
35733587

3574-
letmkILCustomAttribMethRef(ilg:ILGlobals)(mspec:ILMethodSpec,fixedArgs:list<_>,namedArgs:list<_>)=
3588+
letencodeCustomAttrArgs(ilg:ILGlobals)(mspec:ILMethodSpec)(fixedArgs:list<_>)(namedArgs:list<_>)=
35753589
letargtys= mspec.MethodRef.ArgTypes
3576-
letargs=
3577-
[|yield![|0x01uy;0x00uy;|]
3578-
for(argty, fixedArg)in Seq.zip argtys fixedArgsdo
3579-
yield! encodeCustomAttrValue ilg argty fixedArg
3580-
yield! u16AsBytes(uint16 namedArgs.Length)
3581-
for namedArgin namedArgsdo
3582-
yield! encodeCustomAttrNamedArg ilg namedArg|]
3583-
{ Method= mspec
3584-
Data= args
3585-
Elements= fixedArgs@(namedArgs|> List.map(fun(_,_,_,e)-> e))}
3586-
3587-
letmkILCustomAttribute ilg(tref,argtys,argvs,propvs)=
3588-
mkILCustomAttribMethRef ilg(mkILNonGenericCtorMethSpec(tref, argtys), argvs, propvs)
3590+
[|yield![|0x01uy;0x00uy;|]
3591+
for(argty, fixedArg)in Seq.zip argtys fixedArgsdo
3592+
yield! encodeCustomAttrValue ilg argty fixedArg
3593+
yield! u16AsBytes(uint16 namedArgs.Length)
3594+
for namedArgin namedArgsdo
3595+
yield! encodeCustomAttrNamedArg ilg namedArg|]
3596+
3597+
letencodeCustomAttr(ilg:ILGlobals)(mspec:ILMethodSpec,fixedArgs:list<_>,namedArgs:list<_>)=
3598+
letargs= encodeCustomAttrArgs ilg mspec fixedArgs namedArgs
3599+
ILAttribute.Encoded(mspec, args, fixedArgs@(namedArgs|> List.map(fun(_,_,_,e)-> e)))
3600+
3601+
letmkILCustomAttribMethRef(ilg:ILGlobals)(mspec:ILMethodSpec,fixedArgs:list<_>,namedArgs:list<_>)=
3602+
encodeCustomAttr ilg(mspec, fixedArgs, namedArgs)
3603+
3604+
letmkILCustomAttribute ilg(tref,argtys,argvs,propvs)=
3605+
encodeCustomAttr ilg(mkILNonGenericCtorMethSpec(tref, argtys), argvs, propvs)
3606+
3607+
letgetCustomAttrData(ilg:ILGlobals)cattr=
3608+
match cattrwith
3609+
| ILAttribute.Encoded(_, data,_)-> data
3610+
| ILAttribute.Decoded(mspec, fixedArgs, namedArgs)->
3611+
encodeCustomAttrArgs ilg mspec fixedArgs namedArgs
35893612

35903613
letMscorlibScopeRef= ILScopeRef.Assembly(ILAssemblyRef.Create("mscorlib", None, Some ecmaPublicKey,true, None, None))
35913614
letEcmaMscorlibILGlobals= mkILGlobals MscorlibScopeRef
@@ -3754,7 +3777,10 @@ type ILTypeSigParser(tstring : string) =
37543777
ILAttribElem.Type(Some(ilty))
37553778

37563779
letdecodeILAttribData(ilg:ILGlobals)(ca:ILAttribute)=
3757-
letbytes= ca.Data
3780+
match cawith
3781+
| ILAttribute.Decoded(_, fixedArgs, namedArgs)-> fixedArgs, namedArgs
3782+
| ILAttribute.Encoded(_, bytes,_)->
3783+
37583784
letsigptr=0
37593785
letbb0,sigptr= sigptr_get_byte bytes sigptr
37603786
letbb1,sigptr= sigptr_get_byte bytes sigptr
@@ -3943,7 +3969,7 @@ and refs_of_token s x =
39433969
| ILToken.ILMethod mr-> refs_of_mspec s mr
39443970
| ILToken.ILField fr-> refs_of_fspec s fr
39453971

3946-
andrefs_of_custom_attr sx= refs_of_mspec sx.Method
3972+
andrefs_of_custom_attr s(cattr:ILAttribute)= refs_of_mspec scattr.Method
39473973

39483974
andrefs_of_custom_attrs s(cas:ILAttributes)= List.iter(refs_of_custom_attr s) cas.AsList
39493975
andrefs_of_varargs s tyso= Option.iter(refs_of_tys s) tyso

‎src/absil/il.fsi‎

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -752,12 +752,22 @@ type ILAttribElem =
752752
/// Named args: values and flags indicating if they are fields or properties.
753753
typeILAttributeNamedArg= string* ILType* bool* ILAttribElem
754754

755-
/// Custom attributes. See 'decodeILAttribData' for a helper to parse the byte[]
756-
/// to ILAttribElem's as best as possible.
755+
/// Custom attribute.
757756
typeILAttribute=
758-
{ Method:ILMethodSpec
759-
Data:byte[]
760-
Elements:ILAttribElem list}
757+
/// Attribute with args encoded to a binary blob according to ECMA-335 II.21 and II.23.3.
758+
/// 'decodeILAttribData' is used to parse the byte[] blob to ILAttribElem's as best as possible.
759+
| Encodedofmethod:ILMethodSpec*data:byte[]*elements:ILAttribElemlist
760+
761+
/// Attribute with args in decoded form.
762+
| Decodedofmethod:ILMethodSpec*fixedArgs:ILAttribElemlist*namedArgs:ILAttributeNamedArglist
763+
764+
/// Attribute instance constructor.
765+
memberMethod:ILMethodSpec
766+
767+
/// Decoded arguments. May be empty in encoded attribute form.
768+
memberElements:ILAttribElem list
769+
770+
memberWithMethod:method:ILMethodSpec->ILAttribute
761771

762772
[<NoEquality; NoComparison; Struct>]
763773
type ILAttributes=
@@ -1679,6 +1689,8 @@ val mkILCustomAttribute:
16791689
ILAttributeNamedArg list(* named args: values and flags indicating if they are fields or properties*)
16801690
-> ILAttribute
16811691

1692+
val getCustomAttrData: ILGlobals-> ILAttribute-> byte[]
1693+
16821694
val mkPermissionSet: ILGlobals-> ILSecurityAction*(ILTypeRef*(string* ILType* ILAttribElem) list) list-> ILSecurityDecl
16831695

16841696
/// Making code.

‎src/absil/ilmorph.fs‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,19 +136,19 @@ let rec celem_ty2ty f celem =
136136
letcnamedarg_ty2ty f((nm,ty,isProp,elem):ILAttributeNamedArg)=
137137
(nm, f ty, isProp, celem_ty2ty f elem)
138138

139-
letcattr_ty2ty ilg fc=
139+
letcattr_ty2ty ilg f(c:ILAttribute)=
140140
letmeth= mspec_ty2ty(f,(fun _-> f)) c.Method
141141
// dev11 M3 defensive coding: if anything goes wrong with attribute decoding or encoding, then back out.
142142
if morphCustomAttributeDatathen
143143
try
144144
letelems,namedArgs= IL.decodeILAttribData ilg c
145145
letelems= elems|> List.map(celem_ty2ty f)
146146
letnamedArgs= namedArgs|> List.map(cnamedarg_ty2ty f)
147-
IL.mkILCustomAttribMethRef ilg(meth, elems, namedArgs)
148-
with_->
149-
{ cwith Method=meth}
147+
mkILCustomAttribMethRef ilg(meth, elems, namedArgs)
148+
with_->
149+
c.WithMethod(meth)
150150
else
151-
{ cwith Method=meth}
151+
c.WithMethod(meth)
152152

153153

154154
letcattrs_ty2ty ilg f(cs:ILAttributes)=

‎src/absil/ilprint.fs‎

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,14 @@ let tyvar_generator =
3030
// Carry an environment because the way we print method variables
3131
// depends on the gparams of the current scope.
3232
typeppenv=
33-
{ ppenvClassFormals:int;
33+
{ ilGlobals:ILGlobals
34+
ppenvClassFormals:int;
3435
ppenvMethodFormals:int}
3536
letppenv_enter_method mgparams env=
3637
{envwith ppenvMethodFormals=mgparams}
3738
letppenv_enter_tdef gparams env=
3839
{envwith ppenvClassFormals=List.length gparams; ppenvMethodFormals=0}
39-
letmk_ppenv={ ppenvClassFormals=0; ppenvMethodFormals=0}
40+
letmk_ppenvilg={ilGlobals= ilg;ppenvClassFormals=0; ppenvMethodFormals=0}
4041
letdebug_ppenv= mk_ppenv
4142
letppenv_enter_modul env={ envwith ppenvClassFormals=0; ppenvMethodFormals=0}
4243

@@ -469,10 +470,11 @@ let output_basic_type os x =
469470
letoutput_custom_attr_data os data=
470471
output_string os" ="; output_parens output_bytes os data
471472

472-
letgoutput_custom_attr env os attr=
473+
letgoutput_custom_attr env os(attr:ILAttribute)=
473474
output_string os" .custom"
474475
goutput_mspec env os attr.Method
475-
output_custom_attr_data os attr.Data
476+
letdata= getCustomAttrData env.ilGlobals attr
477+
output_custom_attr_data os data
476478

477479
letgoutput_custom_attrs env os(attrs:ILAttributes)=
478480
List.iter(fun attr-> goutput_custom_attr env os attr; output_string os"\n") attrs.AsList
@@ -1029,19 +1031,19 @@ let goutput_manifest env os m =
10291031
output_string os" }\n"
10301032

10311033

1032-
letoutput_module_fragment_aux _refs osmodul=
1034+
letoutput_module_fragment_aux _refs os(ilg:ILGlobals)modul=
10331035
try
1034-
letenv= mk_ppenv
1036+
letenv= mk_ppenvilg
10351037
letenv= ppenv_enter_modul env
10361038
goutput_tdefsfalse([]) env os modul.TypeDefs;
10371039
goutput_tdefstrue([]) env os modul.TypeDefs;
10381040
with e->
10391041
output_string os"*** Error during printing :"; output_string os(e.ToString()); os.Flush();
10401042
reraise()
10411043

1042-
letoutput_module_fragment osmodul=
1044+
letoutput_module_fragment os(ilg:ILGlobals)modul=
10431045
letrefs= computeILRefs modul
1044-
output_module_fragment_aux refs os modul;
1046+
output_module_fragment_aux refs osilg modul
10451047
refs
10461048

10471049
letoutput_module_refs os refs=
@@ -1059,14 +1061,14 @@ let goutput_module_manifest env os modul =
10591061
output_string os"\n";
10601062
(output_option(goutput_manifest env)) os modul.Manifest
10611063

1062-
letoutput_module osmodul=
1064+
letoutput_module os(ilg:ILGlobals)modul=
10631065
try
10641066
letrefs= computeILRefs modul
1065-
letenv= mk_ppenv
1067+
letenv= mk_ppenvilg
10661068
letenv= ppenv_enter_modul env
10671069
output_module_refs os refs;
10681070
goutput_module_manifest env os modul;
1069-
output_module_fragment_aux refs os modul;
1071+
output_module_fragment_aux refs osilg modul;
10701072
with e->
10711073
output_string os"*** Error during printing :"; output_string os(e.ToString()); os.Flush();
10721074
raise e

‎src/absil/ilprint.fsi‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ open Microsoft.FSharp.Compiler.AbstractIL.Internal
99
openSystem.IO
1010

1111
#if DEBUG
12-
valpublicoutput_module:TextWriter->ILModuleDef->unit
12+
valpublicoutput_module:TextWriter->ilg:ILGlobals->ILModuleDef->unit
1313
#endif
1414

‎src/absil/ilread.fs‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2567,12 +2567,13 @@ and seekReadCustomAttr ctxt (TaggedIndex(cat, idx), b) =
25672567

25682568
andseekReadCustomAttrUncached ctxtH(CustomAttrIdx(cat,idx,valIdx))=
25692569
letctxt= getHole ctxtH
2570-
{ Method=seekReadCustomAttrType ctxt(TaggedIndex(cat, idx))
2571-
Data=
2570+
letmethod=seekReadCustomAttrType ctxt(TaggedIndex(cat, idx))
2571+
letdata=
25722572
match readBlobHeapOption ctxt valIdxwith
25732573
| Some bytes-> bytes
2574-
| None-> Bytes.ofInt32Array[||]
2575-
Elements=[]}
2574+
| None-> Bytes.ofInt32Array[||]
2575+
letelements=[]
2576+
ILAttribute.Encoded(method, data, elements)
25762577

25772578
andsecurityDeclsReader ctxtH tag=
25782579
mkILSecurityDeclsReader

‎src/absil/ilreflect.fs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,12 +1414,12 @@ let emitMethodBody cenv modB emEnv ilG _name (mbody: ILLazyMethodBody) =
14141414
| MethodBody.Native-> failwith"emitMethodBody: native"
14151415
| MethodBody.NotAvailable-> failwith"emitMethodBody: metadata only"
14161416

1417-
letconvCustomAttr cenv emEnv cattr=
1417+
letconvCustomAttr cenv emEnv(cattr:ILAttribute)=
14181418
letmethInfo=
14191419
match convConstructorSpec cenv emEnv cattr.Methodwith
14201420
|null-> failwithf"convCustomAttr:%+A" cattr.Method
14211421
| res-> res
1422-
letdata=cattr.Data
1422+
letdata=getCustomAttrData cenv.ilg cattr
14231423
(methInfo, data)
14241424

14251425
letemitCustomAttr cenv emEnv add cattr= add(convCustomAttr cenv emEnv cattr)

‎src/absil/ilwrite.fs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1382,8 +1382,9 @@ and GetMethodRefAsCustomAttribType cenv (mref:ILMethodRef) =
13821382
let recGetCustomAttrDataAsBlobIdx cenv(data:byte[])=
13831383
if data.Length=0then0else GetBytesAsBlobIdx cenv data
13841384

1385-
andGetCustomAttrRow cenv hca attr=
1385+
andGetCustomAttrRow cenv hca(attr:ILAttribute)=
13861386
letcat= GetMethodRefAsCustomAttribType cenv attr.Method.MethodRef
1387+
letdata= getCustomAttrData cenv.ilg attr
13871388
for elementin attr.Elementsdo
13881389
match elementwith
13891390
| ILAttribElem.Type(Some ty)when ty.IsNominal-> GetTypeRefAsTypeRefIdx cenv ty.TypeRef|> ignore
@@ -1393,7 +1394,7 @@ and GetCustomAttrRow cenv hca attr =
13931394
UnsharedRow
13941395
[| HasCustomAttribute(fst hca, snd hca);
13951396
CustomAttributeType(fst cat, snd cat);
1396-
Blob(GetCustomAttrDataAsBlobIdx cenvattr.Data)
1397+
Blob(GetCustomAttrDataAsBlobIdx cenvdata)
13971398
|]
13981399

13991400
andGenCustomAttrPass3Or4 cenv hca attr=

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp