[Mono-devel-list] Type.FilterName Fix

Willibald Krenn Willibald.Krenn at gmx.at
Tue Jan 18 21:07:30 EST 2005


According to MS, Type.FilterName also takes a wildcard as last char:

"This field holds a reference to the delegate used by the FindMembers 
method. The method encapsulated by this delegate takes two parameters: 
the first is a MemberInfo object and the second is an Object. The method 
determines whether the MemberInfo object matches the criteria specified 
by the Object. The Object is assigned a string value, which may include 
a trailing "*" wildcard character. Only wildcard end string matching is 

Current Mono FilterName_impl method does not allow wildcard-searches, so 
I've fixed the method (in Type.cs):

/* implementation of the delegates for MemberFilter */
static bool FilterName_impl (MemberInfo m, object filterCriteria)
	string name = (string) filterCriteria;
	int filterLen = name.Length;

	/* last char can be '*' */
	if (name.EndsWith ("*"))

	return String.Compare (name, 0, m.Name, 0, filterLen, false,
		 CultureInfo.InvariantCulture) == 0;

This version will also work for '*' type of filters, because 
String.Compare(..) returns zero too if filterLen is 0.


More information about the Mono-devel-list mailing list