public override object VisitFieldDeclaration(FieldDeclaration fieldDeclaration, object data) { const Modifiers staticReadOnly = Modifiers.Static | Modifiers.Readonly; if ((fieldDeclaration.Modifiers & staticReadOnly) == staticReadOnly && decimalType.IsMatch(fieldDeclaration.ReturnType)) { foreach (var attributeSection in fieldDeclaration.Attributes) { foreach (var attribute in attributeSection.Attributes) { ITypeDefOrRef tr = attribute.Type.Annotation <ITypeDefOrRef>(); if (tr != null && tr.Compare(systemRuntimeCompilerServicesString, decimalConstantAttributeString)) { attribute.Remove(); if (attributeSection.Attributes.Count == 0) { attributeSection.Remove(); } fieldDeclaration.Modifiers = (fieldDeclaration.Modifiers & ~staticReadOnly) | Modifiers.Const; return(null); } } } } return(null); }
public override bool DoMatch(INode other, Match match) { ComposedType ct = other as ComposedType; AstType o; if (ct != null && !ct.HasNullableSpecifier && ct.PointerRank == 0 && !ct.ArraySpecifiers.Any()) { // Special case: ILSpy sometimes produces a ComposedType but then removed all array specifiers // from it. In that case, we need to look at the base type for the annotations. o = ct.BaseType; } else { o = other as AstType; if (o == null) { return(false); } } ITypeDefOrRef tr = o.Annotation <ITypeDefOrRef>(); return(tr.Compare(ns, name)); }