private void GenerateProperties(IEnumerable <Method> settersToUse, bool readOnly) { foreach (var setter in settersToUse) { Class type = (Class)setter.Namespace; StringBuilder nameBuilder = new StringBuilder(setter.Name.Substring(3)); if (char.IsLower(setter.Name[0])) { nameBuilder[0] = char.ToLowerInvariant(nameBuilder[0]); } string afterSet = nameBuilder.ToString(); var s = setter; foreach (var getter in nonSetters.Where(m => m.Namespace == type && m.ExplicitInterfaceImpl == s.ExplicitInterfaceImpl)) { var name = GetReadWritePropertyName(getter, afterSet); if (name == afterSet && GetUnderlyingType(getter.OriginalReturnType).Equals( GetUnderlyingType(setter.Parameters[0].QualifiedType))) { Method g = getter; foreach (var method in type.Methods.Where(m => m != g && m.Name == name)) { var oldName = method.Name; method.Name = string.Format("get{0}{1}", char.ToUpperInvariant(method.Name[0]), method.Name.Substring(1)); log.Debug("Method {0}::{1} renamed to {2}", method.Namespace.Name, oldName, method.Name); } foreach (var @event in type.Events.Where(e => e.Name == name)) { var oldName = @event.Name; @event.Name = string.Format("on{0}{1}", char.ToUpperInvariant(@event.Name[0]), @event.Name.Substring(1)); log.Debug("Event {0}::{1} renamed to {2}", @event.Namespace.Name, oldName, @event.Name); } getter.Name = name; GenerateProperty(getter.Namespace, getter, readOnly ? null : setter); goto next; } } Property baseProperty = type.GetRootBaseProperty(new Property { Name = afterSet }); if (!type.IsInterface && baseProperty != null && baseProperty.IsVirtual && setter.IsVirtual) { bool isReadOnly = baseProperty.SetMethod == null; GenerateProperty(setter.Namespace, baseProperty.GetMethod, readOnly || isReadOnly ? null : setter); } next: ; } foreach (Method nonSetter in nonSetters) { Class type = (Class)nonSetter.Namespace; string name = GetPropertyName(nonSetter.Name); Property baseProperty = type.GetRootBaseProperty(new Property { Name = name }); if (!type.IsInterface && baseProperty != null && baseProperty.IsVirtual) { bool isReadOnly = baseProperty.SetMethod == null; if (readOnly == isReadOnly) { GenerateProperty(nonSetter.Namespace, nonSetter, readOnly ? null : baseProperty.SetMethod); } } } }
public static void Debug(this IDiagnosticConsumer consumer, string msg, params object[] args) { consumer.Debug(DiagnosticId.None, msg, args); }