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

Commit478dfd7

Browse files
authored
Set serializable bit for all serializable types (#4211)
1 parent5a12cde commit478dfd7

File tree

3 files changed

+11
-16
lines changed

3 files changed

+11
-16
lines changed

‎src/fsharp/IlxGen.fs‎

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3747,8 +3747,8 @@ and GenClosureTypeDefs cenv (tref:ILTypeRef, ilGenParams, attrs, ilCloFreeVars,
37473747
Properties= emptyILProperties
37483748
Methods= mkILMethods mdefs
37493749
MethodImpls= mkILMethodImpls mimpls
3750-
IsSerializable= cenv.g.attrib_SerializableAttribute.IsSome
3751-
IsComInterop=false
3750+
IsSerializable=true
3751+
IsComInterop=false
37523752
IsSpecialName=true
37533753
NestedTypes=emptyILTypeDefs
37543754
Encoding= ILDefaultPInvokeEncoding.Auto
@@ -3803,8 +3803,8 @@ and GenLambdaClosure cenv (cgbuf:CodeGenBuffer) eenv isLocalTypeFunc selfv expr
38033803
Properties= emptyILProperties
38043804
Methods= mkILMethods ilContractMeths
38053805
MethodImpls= emptyILMethodImpls
3806-
IsSerializable= cenv.g.attrib_SerializableAttribute.IsSome
3807-
IsComInterop=false
3806+
IsSerializable=true
3807+
IsComInterop=false
38083808
IsSpecialName=true
38093809
NestedTypes=emptyILTypeDefs
38103810
Encoding= ILDefaultPInvokeEncoding.Auto
@@ -6563,9 +6563,8 @@ and GenTypeDef cenv mgbuf lazyInitInfo eenv m (tycon:Tycon) =
65636563
letilFields= mkILFields ilFieldDefs
65646564

65656565
lettdef,tdefDiscards=
6566-
letisSerializable=(TryFindFSharpBoolAttribute cenv.g cenv.g.attrib_AutoSerializableAttribute tycon.Attribs<> Some(false))
6567-
&& cenv.g.attrib_SerializableAttribute.IsSome
6568-
6566+
letisSerializable=(TryFindFSharpBoolAttribute cenv.g cenv.g.attrib_AutoSerializableAttribute tycon.Attribs<> Some(false))
6567+
65696568
match tycon.TypeReprInfowith
65706569
| TILObjectRepr_->
65716570
lettd= tycon.ILTyconRawMetadata
@@ -6817,11 +6816,10 @@ and GenExnDef cenv mgbuf eenv m (exnc:Tycon) =
68176816
else
68186817
[]
68196818

6820-
68216819
letserializationRelatedMembers=
6822-
// do not emit serialization related members if target framework lacksSerializableAttribute orSerializationInfo
6823-
match cenv.g.attrib_SerializableAttribute, cenv.g.iltyp_SerializationInfo, cenv.g.iltyp_StreamingContextwith
6824-
| Some_, SomeserializationInfoType, Some streamingContextType->
6820+
// do not emit serialization related members if target framework lacksSerializationInfo orStreamingContext
6821+
match cenv.g.iltyp_SerializationInfo, cenv.g.iltyp_StreamingContextwith
6822+
| Some serializationInfoType, Some streamingContextType->
68256823
letilCtorDefForSerialziation=
68266824
mkILCtor(ILMemberAccess.Family,
68276825
[mkILParamNamed("info", serializationInfoType);mkILParamNamed("context",streamingContextType)],
@@ -6880,7 +6878,7 @@ and GenExnDef cenv mgbuf eenv m (exnc:Tycon) =
68806878
emptyILEvents,
68816879
mkILCustomAttrs[mkCompilationMappingAttr cenv.g(int SourceConstructFlags.Exception)],
68826880
ILTypeInit.BeforeField)
6883-
lettdef={ tdefwith IsSerializable=cenv.g.attrib_SerializableAttribute.IsSome}
6881+
lettdef={ tdefwith IsSerializable=true}
68846882
mgbuf.AddTypeDef(tref, tdef,false,false, None)
68856883

68866884

‎src/fsharp/TcGlobals.fs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1005,7 +1005,6 @@ type public TcGlobals(compilingFslib: bool, ilg:ILGlobals, fslibCcu: CcuThunk, d
10051005
member valattrib_ProjectionParameterAttribute= mk_MFCore_attrib"ProjectionParameterAttribute"
10061006
member valattrib_CustomOperationAttribute= mk_MFCore_attrib"CustomOperationAttribute"
10071007
member valattrib_NonSerializedAttribute= tryFindSysAttrib"System.NonSerializedAttribute"
1008-
member valattrib_SerializableAttribute= tryFindSysAttrib"System.SerializableAttribute"
10091008

10101009
member valattrib_AutoSerializableAttribute= mk_MFCore_attrib"AutoSerializableAttribute"
10111010
member valattrib_RequireQualifiedAccessAttribute= mk_MFCore_attrib"RequireQualifiedAccessAttribute"

‎src/fsharp/fsc.fs‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1968,12 +1968,10 @@ let main2b (tcImportsCapture,dynamicAssemblyCreator) (Args (ctok, tcConfig: TcCo
19681968
use unwindBuildPhase= PushThreadBuildPhaseUntilUnwind BuildPhase.IlxGen
19691969
letilxGenerator= CreateIlxAssemblyGenerator(tcConfig, tcImports, tcGlobals,(LightweightTcValForUsingInBuildMethodCall tcGlobals), generatedCcu)
19701970

1971-
// Check if System.SerializableAttribute exists in mscorlib.dll,
1972-
// so that make sure the compiler only emits "serializable" bit into IL metadata when it is available.
1973-
// Note that SerializableAttribute may be relocated in the future but now resides in mscorlib.
19741971
letcodegenResults= GenerateIlxCode((if Option.isSome dynamicAssemblyCreatorthen IlReflectBackendelse IlWriteBackend), Option.isSome dynamicAssemblyCreator,false, tcConfig, topAttrs, optimizedImpls, generatedCcu.AssemblyName, ilxGenerator)
19751972
letcasApplied=new Dictionary<Stamp, bool>()
19761973
letsecurityAttrs,topAssemblyAttrs= topAttrs.assemblyAttrs|> List.partition(fun a-> TypeChecker.IsSecurityAttribute tcGlobals(tcImports.GetImportMap()) casApplied a rangeStartup)
1974+
19771975
// remove any security attributes from the top-level assembly attribute list
19781976
lettopAttrs={topAttrswith assemblyAttrs=topAssemblyAttrs}
19791977
letpermissionSets= ilxGenerator.CreatePermissionSets securityAttrs

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp