Access Arguments/Variables annotations

I do not believe they are accessible.
Here is how I solved it

        // This is the function that executes for each activity in all the files. Might impact performance.
        // The rule instance is the rule provided above which also contains the user-configured data.
        private static InspectionResult Inspect(IWorkflowModel workflowModel, Rule ruleInstance)
        {
            var messageList = new List<string>();

            if (workflowModel.Project.ProjectOutputType == "Library" && !(workflowModel.Project.TestCases.Contains(workflowModel.RelativePath)))
            {
                string workflowFullPath = $@"{workflowModel.Project.Directory}\{workflowModel.RelativePath}";
                string workflowXamlText = File.ReadAllText(workflowFullPath);

                XmlDocument workflowXML = new XmlDocument();
                XmlNamespaceManager nsmgr = new XmlNamespaceManager(workflowXML.NameTable);
                workflowXML.LoadXml(workflowXamlText);
                nsmgr.AddNamespace("ns1", "http://schemas.microsoft.com/netfx/2009/xaml/activities");
                nsmgr.AddNamespace("x", "http://schemas.microsoft.com/winfx/2006/xaml");

                XmlNodeList annotationsNodeList = workflowXML.SelectNodes("/ns1:Activity/x:Members/x:Property", nsmgr);

                foreach (XmlNode annotationNode in annotationsNodeList)
                {
                    if (annotationNode.Attributes["sap2010:Annotation.AnnotationText"] is null)
                    {
                        messageList.Add($"The annotation {annotationNode.Attributes["Name"].Value} requires an annotation.");
                    }
                }
            }

            if (messageList.Count > 0)
            {
                return new InspectionResult()
                {
                    ErrorLevel = ruleInstance.ErrorLevel,
                    HasErrors = true,
                    RecommendationMessage = ruleInstance.RecommendationMessage,
                    // When inspecting a model, a rule can generate more than one message.
                    Messages = messageList
                };
            }
            else
            {
                return new InspectionResult() { HasErrors = false };
            }
        }

It is worth noting, there are two ways annotations can be stored in the xaml file, so this only checks for one of them.

2 Likes