@@ -140,57 +140,9 @@ static bool CheckSerializable (object o)
140140 private static SharedObjectsState SaveRuntimeDataObjects ( )
141141 {
142142 var contexts = new Dictionary < PyObject , Dictionary < string , object ? > > ( PythonReferenceComparer . Instance ) ;
143- var extensionObjs = new Dictionary < PyObject , ExtensionType > ( PythonReferenceComparer . Instance ) ;
144- // make a copy with strongly typed references to avoid concurrent modification
145- var extensions = ExtensionType . loadedExtensions
146- . Select ( addr => new PyObject (
147- new BorrowedReference ( addr ) ,
148- // if we don't skip collect, finalizer might modify loadedExtensions
149- skipCollect : true ) )
150- . ToArray ( ) ;
151- foreach ( var pyObj in extensions )
152- {
153- var extension = ( ExtensionType ) ManagedType . GetManagedObject ( pyObj ) ! ;
154- Debug . Assert ( CheckSerializable ( extension ) ) ;
155- var context = extension . Save ( pyObj ) ;
156- if ( context is not null )
157- {
158- contexts [ pyObj ] = context ;
159- }
160- extensionObjs . Add ( pyObj , extension ) ;
161- }
162143
163144 var wrappers = new Dictionary < object , List < CLRObject > > ( ) ;
164145 var userObjects = new CLRWrapperCollection ( ) ;
165- // make a copy with strongly typed references to avoid concurrent modification
166- var reflectedObjects = CLRObject . reflectedObjects
167- . Select ( addr => new PyObject (
168- new BorrowedReference ( addr ) ,
169- // if we don't skip collect, finalizer might modify reflectedObjects
170- skipCollect : true ) )
171- . ToList ( ) ;
172- foreach ( var pyObj in reflectedObjects )
173- {
174- // Wrapper must be the CLRObject
175- var clrObj = ( CLRObject ) ManagedType . GetManagedObject ( pyObj ) ! ;
176- object inst = clrObj . inst ;
177- List < CLRObject > mappedObjs ;
178- if ( ! userObjects . TryGetValue ( inst , out var item ) )
179- {
180- item = new CLRMappedItem ( inst ) ;
181- userObjects . Add ( item ) ;
182-
183- Debug . Assert ( ! wrappers . ContainsKey ( inst ) ) ;
184- mappedObjs = new List < CLRObject > ( ) ;
185- wrappers . Add ( inst , mappedObjs ) ;
186- }
187- else
188- {
189- mappedObjs = wrappers [ inst ] ;
190- }
191- item . AddRef ( pyObj ) ;
192- mappedObjs . Add ( clrObj ) ;
193- }
194146
195147 var wrapperStorage = new Dictionary < string , object ? > ( ) ;
196148 WrappersStorer ? . Store ( userObjects , wrapperStorage ) ;
@@ -215,7 +167,6 @@ private static SharedObjectsState SaveRuntimeDataObjects()
215167 return new ( )
216168 {
217169 InternalStores = internalStores ,
218- Extensions = extensionObjs ,
219170 Wrappers = wrapperStorage ,
220171 Contexts = contexts ,
221172 } ;
0 commit comments