@@ -182,9 +182,9 @@ private bool HasBindableAttribute(TypeDefinition type)
182182 attr . AttributeType . FullName == "Uno.Extensions.Reactive.Bindings.BindableAttribute" ) ;
183183 }
184184
185- private Dictionary < string , TypeDefinition > FindReferencedTypes ( List < TypeDefinition > bindableTypes )
185+ private Dictionary < TypeDefinition , HashSet < string > > FindReferencedTypes ( List < TypeDefinition > bindableTypes )
186186 {
187- var referencedTypes = new Dictionary < string , TypeDefinition > ( ) ;
187+ var referencedTypes = new Dictionary < TypeDefinition , HashSet < string > > ( ) ;
188188
189189 foreach ( var bindableType in bindableTypes )
190190 {
@@ -199,7 +199,7 @@ private Dictionary<string, TypeDefinition> FindReferencedTypes(List<TypeDefiniti
199199 return referencedTypes ;
200200 }
201201
202- private void ProcessPropertyType ( TypeReference propertyType , Dictionary < string , TypeDefinition > referencedTypes )
202+ private void ProcessPropertyType ( TypeReference propertyType , Dictionary < TypeDefinition , HashSet < string > > referencedTypes )
203203 {
204204 // Resolve the type
205205 TypeDefinition ? resolvedType = null ;
@@ -231,7 +231,7 @@ private void ProcessPropertyType(TypeReference propertyType, Dictionary<string,
231231 }
232232 }
233233
234- private void AddTypeIfNeeded ( TypeDefinition resolvedType , Dictionary < string , TypeDefinition > referencedTypes )
234+ private void AddTypeIfNeeded ( TypeDefinition resolvedType , Dictionary < TypeDefinition , HashSet < string > > referencedTypes )
235235 {
236236 // Skip if type already has Bindable attribute
237237 if ( HasBindableAttribute ( resolvedType ) )
@@ -240,22 +240,34 @@ private void AddTypeIfNeeded(TypeDefinition resolvedType, Dictionary<string, Typ
240240 return ;
241241 }
242242
243- // Skip if type has no properties
244- if ( ! resolvedType . Properties . Any ( ) )
243+ // Get all public properties with getters
244+ var publicProperties = resolvedType . Properties
245+ . Where ( p => p . GetMethod ? . IsPublic == true )
246+ . Select ( p => p . Name )
247+ . ToList ( ) ;
248+
249+ // Skip if type has no public properties
250+ if ( ! publicProperties . Any ( ) )
245251 {
246- Log . LogMessage ( MessageImportance . Low , $ "Skipping { resolvedType . FullName } - has no properties") ;
252+ Log . LogMessage ( MessageImportance . Low , $ "Skipping { resolvedType . FullName } - has no public properties") ;
247253 return ;
248254 }
249255
250- // Add to referenced types
251- if ( ! referencedTypes . ContainsKey ( resolvedType . FullName ) )
256+ // Add or update the type with its properties
257+ if ( ! referencedTypes . ContainsKey ( resolvedType ) )
252258 {
253- referencedTypes [ resolvedType . FullName ] = resolvedType ;
259+ referencedTypes [ resolvedType ] = new HashSet < string > ( ) ;
254260 Log . LogMessage ( DefaultLogMessageLevel , $ "BindableTypeLinkerGenerator: Adding referenced type { resolvedType . FullName } ") ;
255261 }
262+
263+ // Add all public properties to the set
264+ foreach ( var propName in publicProperties )
265+ {
266+ referencedTypes [ resolvedType ] . Add ( propName ) ;
267+ }
256268 }
257269
258- private void GenerateLinkerDescriptor ( Dictionary < string , TypeDefinition > referencedTypes )
270+ private void GenerateLinkerDescriptor ( Dictionary < TypeDefinition , HashSet < string > > referencedTypes )
259271 {
260272 var doc = new XmlDocument ( ) ;
261273
@@ -266,8 +278,8 @@ private void GenerateLinkerDescriptor(Dictionary<string, TypeDefinition> referen
266278 doc . AppendChild ( linkerNode ) ;
267279
268280 // Group types by assembly
269- var typesByAssembly = referencedTypes . Values
270- . GroupBy ( t => t . Module . Assembly . Name . Name )
281+ var typesByAssembly = referencedTypes
282+ . GroupBy ( kvp => kvp . Key . Module . Assembly . Name . Name )
271283 . OrderBy ( g => g . Key ) ;
272284
273285 foreach ( var assemblyGroup in typesByAssembly )
@@ -277,22 +289,31 @@ private void GenerateLinkerDescriptor(Dictionary<string, TypeDefinition> referen
277289 fullnameAttr . Value = assemblyGroup . Key ;
278290 assemblyNode . Attributes . Append ( fullnameAttr ) ;
279291
280- foreach ( var type in assemblyGroup . OrderBy ( t => t . FullName ) )
292+ foreach ( var typeEntry in assemblyGroup . OrderBy ( t => t . Key . FullName ) )
281293 {
294+ var type = typeEntry . Key ;
295+ var properties = typeEntry . Value ;
296+
282297 var typeNode = doc . CreateElement ( "type" ) ;
283298
284299 var typeFullnameAttr = doc . CreateAttribute ( "fullname" ) ;
285300 typeFullnameAttr . Value = type . FullName ;
286301 typeNode . Attributes . Append ( typeFullnameAttr ) ;
287302
288- var preserveAttr = doc . CreateAttribute ( "preserve" ) ;
289- preserveAttr . Value = "methods" ;
290- typeNode . Attributes . Append ( preserveAttr ) ;
291-
292303 var requiredAttr = doc . CreateAttribute ( "required" ) ;
293304 requiredAttr . Value = "false" ;
294305 typeNode . Attributes . Append ( requiredAttr ) ;
295306
307+ // Add property elements for each public property
308+ foreach ( var propName in properties . OrderBy ( p => p ) )
309+ {
310+ var propertyNode = doc . CreateElement ( "property" ) ;
311+ var nameAttr = doc . CreateAttribute ( "name" ) ;
312+ nameAttr . Value = propName ;
313+ propertyNode . Attributes . Append ( nameAttr ) ;
314+ typeNode . AppendChild ( propertyNode ) ;
315+ }
316+
296317 assemblyNode . AppendChild ( typeNode ) ;
297318 }
298319
0 commit comments