@@ -878,26 +878,19 @@ type TcGlobals(
878
878
let tref_CompilerGeneratedAttribute = findSysILTypeRef tname_ CompilerGeneratedAttribute
879
879
let tref_InternalsVisibleToAttribute = findSysILTypeRef tname_ InternalsVisibleToAttribute
880
880
881
- let mutable generatedAttribsCache = []
882
- let mutable debuggerBrowsableNeverAttributeCache = None
883
- let mkDebuggerNonUserCodeAttribute () = mkILCustomAttribute ( findSysILTypeRef tname_ DebuggerNonUserCodeAttribute, [], [], [])
884
- let mkCompilerGeneratedAttribute () = mkILCustomAttribute ( tref_ CompilerGeneratedAttribute, [], [], [])
881
+ let debuggerNonUserCodeAttribute = mkILCustomAttribute ( findSysILTypeRef tname_ DebuggerNonUserCodeAttribute, [], [], [])
882
+ let compilerGeneratedAttribute = mkILCustomAttribute ( tref_ CompilerGeneratedAttribute, [], [], [])
883
+ let generatedAttributes = if noDebugAttributes then [||] else [| compilerGeneratedAttribute; debuggerNonUserCodeAttribute |]
885
884
let compilerGlobalState = CompilerGlobalState()
886
885
887
886
// Requests attributes to be added to compiler generated methods.
888
887
let addGeneratedAttrs ( attrs : ILAttributes ) =
889
- let attribs =
890
- match generatedAttribsCache with
891
- | [] ->
892
- let res = [
893
- if not noDebugAttributes then
894
- mkCompilerGeneratedAttribute()
895
- mkDebuggerNonUserCodeAttribute()
896
- ]
897
- generatedAttribsCache <- res
898
- res
899
- | res -> res
900
- mkILCustomAttrs ( attrs.AsList() @ attribs)
888
+ if Array.isEmpty generatedAttributes then
889
+ attrs
890
+ else
891
+ match attrs.AsArray() with
892
+ | [||] -> mkILCustomAttrsFromArray generatedAttributes
893
+ | attrs -> mkILCustomAttrsFromArray ( Array.append attrs generatedAttributes)
901
894
902
895
let addMethodGeneratedAttrs ( mdef : ILMethodDef ) = mdef.With( customAttrs = addGeneratedAttrs mdef.CustomAttrs)
903
896
@@ -911,15 +904,9 @@ type TcGlobals(
911
904
ILType.Value ( mkILNonGenericTySpec tref)
912
905
mkILCustomAttribute ( findSysILTypeRef tname_ DebuggerBrowsableAttribute, [ typ_ DebuggerBrowsableState], [ ILAttribElem.Int32 n], [])
913
906
914
- let mkDebuggerBrowsableNeverAttribute () =
915
- match debuggerBrowsableNeverAttributeCache with
916
- | None ->
917
- let res = tref_ DebuggerBrowsableAttribute 0
918
- debuggerBrowsableNeverAttributeCache <- Some res
919
- res
920
- | Some res -> res
907
+ let debuggerBrowsableNeverAttribute = tref_ DebuggerBrowsableAttribute 0
921
908
922
- let addNeverAttrs ( attrs : ILAttributes ) = mkILCustomAttrs ( attrs.AsList () @ [ mkDebuggerBrowsableNeverAttribute () ])
909
+ let addNeverAttrs ( attrs : ILAttributes ) = mkILCustomAttrsFromArray ( Array.append ( attrs.AsArray ()) [| debuggerBrowsableNeverAttribute | ])
923
910
924
911
let addPropertyNeverAttrs ( pdef : ILPropertyDef ) = pdef.With( customAttrs = addNeverAttrs pdef.CustomAttrs)
925
912
@@ -1837,13 +1824,7 @@ type TcGlobals(
1837
1824
1838
1825
member _.mkDebuggerDisplayAttribute s = mkILCustomAttribute ( findSysILTypeRef tname_ DebuggerDisplayAttribute, [ ilg.typ_ String], [ ILAttribElem.String ( Some s)], [])
1839
1826
1840
- member _.DebuggerBrowsableNeverAttribute = mkDebuggerBrowsableNeverAttribute()
1841
-
1842
- member _.mkDebuggerStepThroughAttribute () =
1843
- mkILCustomAttribute ( findSysILTypeRef tname_ DebuggerStepThroughAttribute, [], [], [])
1844
-
1845
- member _.mkDebuggableAttribute jitOptimizerDisabled =
1846
- mkILCustomAttribute ( tref_ DebuggableAttribute, [ ilg.typ_ Bool; ilg.typ_ Bool], [ ILAttribElem.Bool false ; ILAttribElem.Bool jitOptimizerDisabled], [])
1827
+ member _.DebuggerBrowsableNeverAttribute = debuggerBrowsableNeverAttribute
1847
1828
1848
1829
member _.mkDebuggableAttributeV2 ( jitTracking , jitOptimizerDisabled , enableEnC ) =
1849
1830
let debuggingMode =
@@ -1858,9 +1839,9 @@ type TcGlobals(
1858
1839
1859
1840
member internal _.CompilerGlobalState = Some compilerGlobalState
1860
1841
1861
- member _.CompilerGeneratedAttribute = mkCompilerGeneratedAttribute ()
1842
+ member _.CompilerGeneratedAttribute = compilerGeneratedAttribute
1862
1843
1863
- member _.DebuggerNonUserCodeAttribute = mkDebuggerNonUserCodeAttribute ()
1844
+ member _.DebuggerNonUserCodeAttribute = debuggerNonUserCodeAttribute
1864
1845
1865
1846
member _.MakeInternalsVisibleToAttribute ( simpleAssemName ) =
1866
1847
mkILCustomAttribute ( tref_ InternalsVisibleToAttribute, [ ilg.typ_ String], [ ILAttribElem.String ( Some simpleAssemName)], [])
0 commit comments