void CheckExplicitTypeForVisibleMember(TypeMember node) { if (node.IsSynthetic || !node.IsVisible) { return; } switch (node.NodeType) //TODO: introduce INodeWithType? { case NodeType.Constructor: CheckExplicitParametersType(node); return; case NodeType.Method: var method = (Method)node; if (method.IsPropertyAccessor()) { return; //ignore accessors } CheckExplicitParametersType(node); if (method.ReturnType != null) { return; } if (method.Entity != null && ((IMethod)method.Entity).ReturnType == TypeSystemServices.VoidType) { return; } break; case NodeType.Property: if (null != ((Property)node).Type) { return; } break; case NodeType.Event: if (null != ((Event)node).Type) { return; } break; default: return; //fields, nested types etc... } Warnings.Add(CompilerWarningFactory.VisibleMemberDoesNotDeclareTypeExplicitely(node)); }
void CheckExplicitParametersType(TypeMember node) { INodeWithParameters @params = node as INodeWithParameters; if (null == @params) { return; } foreach (ParameterDeclaration p in @params.Parameters) { if (null == p.Type) { Warnings.Add(CompilerWarningFactory.VisibleMemberDoesNotDeclareTypeExplicitely(node, p.Name)); } } }