public AnalysisActions Analyze(RapidXamlElement element, ExtraAnalysisDetails extraDetails) { if (!element.ContainsAttribute("OnLoaded")) { return(AutoFixAnalysisActions.AddAttribute("OnLoaded", "OnLoadedEventHandler")); } else { return(AutoFixAnalysisActions.None); } }
public AnalysisActions Analyze(RapidXamlElement element, ExtraAnalysisDetails extraDetails) { if (!element.ContainsAttribute("Bar")) { return(AnalysisActions.AddAttribute( RapidXamlErrorType.Warning, code: "CRXT888", description: "Always specify the 'Bar' attribute", actionText: "Add missing 'Bar' attribute", addAttributeName: "Bar", addAttributeValue: "TODO-SET-THIS")); } else { return(AnalysisActions.None); } }
public AnalysisActions Analyze(RapidXamlElement element) { // TODO: Implement this analyzer as per your needs. // More details at https://github.com/mrlacey/Rapid-XAML-Toolkit/blob/master/docs/custom-analysis.md if (element.ContainsAttribute("IsEnabled")) { return(AnalysisActions.None); } else { return(AnalysisActions.AddAttribute( errorType: RapidXamlErrorType.Warning, code: "XMPL01", description: "Always set the 'IsEnabled' property on 'MyElement'.", actionText: "Add 'IsEnabled' attribute", addAttributeName: "IsEnabled", addAttributeValue: "True" )); } }
public override AnalysisActions Analyze(RapidXamlElement element, ExtraAnalysisDetails extraDetails) { AnalysisActions result = AnalysisActions.None; if (!element.HasAttribute(Attributes.Keyboard)) { string nonDefaultSuggestion = null; var xaml = element.OriginalString.ToLowerInvariant(); if (xaml.Contains("email")) { nonDefaultSuggestion = "Email"; } else if (xaml.Contains("phone") || xaml.Contains("cell") || xaml.Contains("mobile")) { nonDefaultSuggestion = "Telephone"; } else if (xaml.Contains("url")) { nonDefaultSuggestion = "Url"; } result.AddAttribute( RapidXamlErrorType.Suggestion, "RXT300", description: StringRes.UI_XamlAnalysisEntryWithoutKeyboardDescription, actionText: StringRes.UI_UndoContextAddEntryKeyboard, addAttributeName: Attributes.Keyboard, addAttributeValue: "Default", extendedMessage: StringRes.UI_XamlAnalysisEntryWithoutKeyboardExtendedMessage); if (!string.IsNullOrEmpty(nonDefaultSuggestion)) { result.OrAddAttribute( actionText: StringRes.UI_AddEntryKeyboard.WithParams(nonDefaultSuggestion), addAttributeName: Attributes.Keyboard, addAttributeValue: nonDefaultSuggestion); } } var txtAttr = element.GetAttributes(Attributes.Text).FirstOrDefault(); if (txtAttr != null && txtAttr.HasStringValue) { var value = txtAttr.StringValue; // TODO: ISSUE#163 change this to an RXT200 when can handle localization of Xamarin.Forms apps if (!string.IsNullOrWhiteSpace(value) && char.IsLetterOrDigit(value[0])) { result.HighlightAttributeWithoutAction( errorType: RapidXamlErrorType.Warning, code: "RXT201", description: StringRes.UI_XamlAnalysisGenericHardCodedStringDescription.WithParams(Elements.Entry, Attributes.Text, value), attribute: txtAttr); } } var phAttr = element.GetAttributes(Attributes.Placeholder).FirstOrDefault(); if (phAttr != null && phAttr.HasStringValue) { var value = phAttr.StringValue; // TODO: ISSUE#163 change this to an RXT200 when can handle localization of Xamarin.Forms apps if (!string.IsNullOrWhiteSpace(value) && char.IsLetterOrDigit(value[0])) { result.HighlightAttributeWithoutAction( errorType: RapidXamlErrorType.Warning, code: "RXT201", description: StringRes.UI_XamlAnalysisGenericHardCodedStringDescription.WithParams(Elements.Entry, Attributes.Placeholder, value), attribute: phAttr); } } var isPwdAttr = element.GetAttributes(Attributes.IsPassword).FirstOrDefault(); if (isPwdAttr != null && isPwdAttr.HasStringValue) { var value = isPwdAttr.StringValue; if (value.Equals("true", StringComparison.InvariantCultureIgnoreCase)) { if (!element.ContainsAttribute(Attributes.MaxLength)) { result.AddAttribute( errorType: RapidXamlErrorType.Suggestion, code: "RXT301", description: StringRes.UI_XamlAnalysisPasswordWithoutMaxLengthDescription, extendedMessage: StringRes.UI_XamlAnalysisPasswordWithoutMaxLengthExtendedMessage, actionText: StringRes.UI_UndoContextAddMaxLangthProperty, addAttributeName: Attributes.MaxLength, addAttributeValue: "100"); } } } return(result); }