Skip to content

Commit

Permalink
Revert ILTypeDef custom attributes changes (dotnet#17503)
Browse files Browse the repository at this point in the history
  • Loading branch information
auduchinok committed Aug 15, 2024
1 parent 5e035e2 commit c9bed79
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 26 deletions.
8 changes: 4 additions & 4 deletions src/Compiler/AbstractIL/il.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2686,7 +2686,7 @@ type ILTypeDef
properties,
additionalFlags,
storeILSecurityDecls securityDecls,
storeILCustomAttrs customAttrs,
customAttrs,
NoMetadataIdx
)

Expand Down Expand Up @@ -2762,7 +2762,7 @@ type ILTypeDef
events = defaultArg events x.Events,
properties = defaultArg properties x.Properties,
additionalFlags = defaultArg newAdditionalFlags additionalFlags,
customAttrs = defaultArg customAttrs (x.CustomAttrs)
customAttrs = defaultArg customAttrs (x.CustomAttrsStored)
)

member x.CustomAttrs: ILAttributes =
Expand Down Expand Up @@ -4259,7 +4259,7 @@ let mkILGenericClass (nm, access, genparams, extends, impl, methods, fields, nes
methods = methods,
fields = fields,
nestedTypes = nestedTypes,
customAttrs = attrs,
customAttrs = storeILCustomAttrs attrs,
methodImpls = emptyILMethodImpls,
properties = props,
events = events,
Expand All @@ -4284,7 +4284,7 @@ let mkRawDataValueTypeDef (iltyp_ValueType: ILType) (nm, size, pack) =
methods = emptyILMethods,
fields = emptyILFields,
nestedTypes = emptyILTypeDefs,
customAttrs = emptyILCustomAttrs,
customAttrs = emptyILCustomAttrsStored,
methodImpls = emptyILMethodImpls,
properties = emptyILProperties,
events = emptyILEvents,
Expand Down
4 changes: 2 additions & 2 deletions src/Compiler/AbstractIL/il.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -1548,7 +1548,7 @@ type ILTypeDef =
properties: ILPropertyDefs *
additionalFlags: ILTypeDefAdditionalFlags *
securityDecls: ILSecurityDecls *
customAttrs: ILAttributes ->
customAttrs: ILAttributesStored ->
ILTypeDef

member Name: string
Expand Down Expand Up @@ -1616,7 +1616,7 @@ type ILTypeDef =
?events: ILEventDefs *
?properties: ILPropertyDefs *
?newAdditionalFlags: ILTypeDefAdditionalFlags *
?customAttrs: ILAttributes *
?customAttrs: ILAttributesStored *
?securityDecls: ILSecurityDecls *
?implementsCustomAttrs: (ILAttributesStored * int) list option ->
ILTypeDef
Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/AbstractIL/ilmorph.fs
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ let rec tdef_ty2ty_ilmbody2ilmbody_mdefs2mdefs isInKnownSet enc fs (tdef: ILType
methodImpls = mimpls_ty2ty fTyInCtxtR tdef.MethodImpls,
events = edefs_ty2ty fTyInCtxtR tdef.Events,
properties = pdefs_ty2ty fTyInCtxtR tdef.Properties,
customAttrs = cattrs_ty2ty fTyInCtxtR tdef.CustomAttrs
customAttrs = storeILCustomAttrs (cattrs_ty2ty fTyInCtxtR tdef.CustomAttrs)
)

and tdefs_ty2ty_ilmbody2ilmbody_mdefs2mdefs isInKnownSet enc fs tdefs =
Expand Down
4 changes: 2 additions & 2 deletions src/Compiler/CodeGen/EraseClosures.fs
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ let rec convIlxClosureDef cenv encl (td: ILTypeDef) clo =
extends = Some cenv.mkILTyFuncTy,
methods = mkILMethods (ctorMethodDef :: nowApplyMethDef :: nowMethods),
fields = mkILFields (mkILCloFldDefs cenv nowFields @ td.Fields.AsList()),
customAttrs = emptyILCustomAttrs,
customAttrs = emptyILCustomAttrsStored,
methodImpls = emptyILMethodImpls,
properties = emptyILProperties,
events = emptyILEvents,
Expand Down Expand Up @@ -714,7 +714,7 @@ let rec convIlxClosureDef cenv encl (td: ILTypeDef) clo =
extends = Some nowEnvParentClass,
methods = mkILMethods (ctorMethodDef :: nowApplyMethDef :: nowMethods),
fields = mkILFields (mkILCloFldDefs cenv nowFields @ td.Fields.AsList()),
customAttrs = emptyILCustomAttrs,
customAttrs = emptyILCustomAttrsStored,
methodImpls = emptyILMethodImpls,
properties = emptyILProperties,
events = emptyILEvents,
Expand Down
5 changes: 3 additions & 2 deletions src/Compiler/CodeGen/EraseUnions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1574,7 +1574,7 @@ let mkClassUnionDef
events = emptyILEvents,
properties = emptyILProperties,
additionalFlags = ILTypeDefAdditionalFlags.None,
customAttrs = emptyILCustomAttrs
customAttrs = emptyILCustomAttrsStored
)
.WithNestedAccess(cud.UnionCasesAccessibility)
.WithAbstract(true)
Expand Down Expand Up @@ -1621,8 +1621,9 @@ let mkClassUnionDef
td.CustomAttrs.AsArray()
|> Array.append [| GetNullableAttribute g [ FSharp.Compiler.TypedTree.NullnessInfo.WithNull ] |]
|> mkILCustomAttrsFromArray
|> storeILCustomAttrs
else
td.CustomAttrs
td.CustomAttrsStored
)
// The .cctor goes on the Cases type since that's where the constant fields for nullary constructors live
|> addConstFieldInit
Expand Down
7 changes: 5 additions & 2 deletions src/Compiler/CodeGen/IlxGen.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1924,7 +1924,7 @@ type TypeDefBuilder(tdef: ILTypeDef, tdefDiscards) =
properties = mkILProperties (tdef.Properties.AsList() @ HashRangeSorted gproperties),
events = mkILEvents (ResizeArray.toList gevents),
nestedTypes = mkILTypeDefs (tdef.NestedTypes.AsList() @ gnested.Close(g)),
customAttrs = attrs
customAttrs = storeILCustomAttrs attrs
)

member _.AddEventDef edef = gevents.Add edef
Expand Down Expand Up @@ -6237,6 +6237,7 @@ and GenStructStateMachine cenv cgbuf eenvouter (res: LoweredStateMachine) sequel
mkCompilationMappingAttr g (int SourceConstructFlags.Closure)
]
|> mkILCustomAttrs
|> storeILCustomAttrs

let cloTypeDef =
ILTypeDef(
Expand Down Expand Up @@ -6670,6 +6671,7 @@ and GenClosureTypeDefs
let customAttrs =
attrs @ [ mkCompilationMappingAttr g (int SourceConstructFlags.Closure) ]
|> mkILCustomAttrs
|> storeILCustomAttrs

let tdef =
ILTypeDef(
Expand Down Expand Up @@ -11370,7 +11372,7 @@ and GenTypeDef cenv mgbuf lazyInitInfo eenv m (tycon: Tycon) : ILTypeRef option
| TILObjectRepr _ ->
let tdef = tycon.ILTyconRawMetadata.WithAccess tyconAccess

let customAttrs = ilCustomAttrs |> mkILCustomAttrs
let customAttrs = ilCustomAttrs |> mkILCustomAttrs |> storeILCustomAttrs

let tdef = tdef.With(customAttrs = customAttrs, genericParams = ilGenParams)

Expand Down Expand Up @@ -11594,6 +11596,7 @@ and GenTypeDef cenv mgbuf lazyInitInfo eenv m (tycon: Tycon) : ILTypeRef option
))
]
|> mkILCustomAttrs
|> storeILCustomAttrs

let tdef =
ILTypeDef(
Expand Down
Loading

0 comments on commit c9bed79

Please sign in to comment.