• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

luttje / Key2Joy / 6517266969

14 Oct 2023 11:05AM UTC coverage: 12.469% (+0.2%) from 12.308%
6517266969

push

github

web-flow
Implementing plugins for better separation (#39)

* Start implementing plugins for better separation
* massive refactor in attempt to split appdomains for plugins
* (breaks old mapping profiles)
* Fix error when switching from mouse button trigger to keyboard trigger and clicking in the combobox where the mouse button capture textbox is.
* Simplify code by removing legacy
* SImplify grouping actions
* Fix profile and add helpful opposite mapping generator tool
* Change solution hierarchy
* Restrict AppDomain plugins went from Zone.MyComputer -> .Internet
* create keypair in ci
* Install the .NET framework tools
* Run command in workflow
* Plugin permissions. Plugins disabled by default
* update readme (icon is no longer used)
* Plugin action runs in seperated process
* Remove unused dependencies.
* Fix action name display for mapping
* Fix Lua plugin script calls (NOTE: laggy when using MessageBox)
* convert project to sdk style
* Add editorconfig and start cleaning up
* Fix documentation. Update namespaces to match files (breaks profiles)
* Include all projects in tests, disable building docs on debug
* Add messagebox script action
* Add tests for pluginhost
* Remove administrator from window title test
* add some icons to ui
* Add enabling/disabling plugins
* Close plugins when Key2Joy shuts down
* Fix appcommand failing
* Fix plugin permission form crashing. Fix plugin load exception not showing warning
* Handle plugin host closing better when app has crashed
* Seperate host and client logic in remote event subscriber
* Ensure the PluginHost shuts down if the app crashes
* Better error output for plugins
* Fix cmd interop not working, add some tests
* also generate docs on plugins
* Fix build order with docs
* Fix enum script parameters and ensure actions share environment scopes
* Fix _wpftmp folders being created dotnet/wpf#2930
* Fix sequence action. Add disabled trigger/action for unloaded plugins on start... (continued)

180 of 1703 branches covered (0.0%)

Branch coverage included in aggregate %.

6419 of 6419 new or added lines in 207 files covered. (100.0%)

1035 of 8041 relevant lines covered (12.87%)

8445.05 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/Support/BuildMarkdownDocs/FunctionMember.cs
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Xml.Linq;
6
using BuildMarkdownDocs.Util;
7

8
namespace BuildMarkdownDocs;
9

10
internal class FunctionMember : Member
11
{
12
    public Example[] MarkdownExamples { get; set; }
×
13
    public Parameter[] Parameters { get; set; }
×
14
    public ReturnType ReturnType { get; set; }
×
15
    public bool IsPlugin { get; set; }
×
16

17
    public string GetParametersSignature()
18
    {
×
19
        if (this.Parameters == null)
×
20
        {
×
21
            return string.Empty;
×
22
        }
23

24
        return string.Join(", ", this.Parameters?
×
25
                .Select(p => $"```{p.GetTypeName()}```"));
×
26
    }
×
27

28
    internal static Member FromXml(XElement element, bool isPlugin = false)
29
    {
×
30
        // Get the parameter types from member attribute, e.g: <member name="M:Key2Joy.Mapping.KeyboardAction.ExecuteForScript(System.Windows.Forms.Keys,Key2Joy.Input.PressState)">
31
        var memberName = element.Attribute("name").Value;
×
32
        var parametersStart = memberName.IndexOf('(');
×
33
        Type[] parameterTypes;
34

35
        if (parametersStart > -1)
×
36
        {
×
37
            var parametersEnd = memberName.LastIndexOf(')') - 1;
×
38
            var parameters = memberName.Substring(parametersStart + 1, memberName.Length - parametersStart - (memberName.Length - parametersEnd));
×
39
            parameterTypes = parameters.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
×
40
                .Select(TypeUtil.GetType)
×
41
                .ToArray();
×
42
        }
×
43
        else
44
        {
×
45
            parameterTypes = new Type[0];
×
46
        }
×
47

48
        FunctionMember member = new()
×
49
        {
×
50
            Name = element.Element("name")?.Value ?? element.Attribute("name").Value
×
51
        };
×
52

53
        var summaryNodes = element.Element("summary").Nodes();
×
54
        StringBuilder summary = new();
×
55

56
        foreach (var node in summaryNodes)
×
57
        {
×
58
            if (node is XElement nodeElement)
×
59
            {
×
60
                if (nodeElement.Name == "see")
×
61
                {
×
62
                    var href = nodeElement.Attribute("href")?.Value;
×
63
                    var cref = nodeElement.Attribute("cref")?.Value;
×
64

65
                    if (href != null)
×
66
                    {
×
67
                        var content = string.IsNullOrEmpty(nodeElement.Value) ? href : nodeElement.Value;
×
68
                        summary.Append($"[{content}]({href})");
×
69
                    }
×
70
                    else
71
                    {
×
72
                        summary.Append($"`{cref}`");
×
73
                    }
×
74
                }
×
75
                else
76
                {
×
77
                    summary.Append(nodeElement.Value.TrimEachLine());
×
78
                }
×
79
            }
×
80
            else
81
            {
×
82
                summary.Append(node.ToString().TrimEachLine());
×
83
            }
×
84
        }
×
85

86
        member.Summary = summary.ToString();
×
87

88
        var returnTypeEl = element.Element("returns");
×
89
        var methodInfo = TypeUtil.GetMethodInfo(memberName);
×
90
        member.ReturnType = returnTypeEl != null ? ReturnType.FromXml(returnTypeEl, methodInfo) : null;
×
91

92
        var i = 0;
×
93
        if (parameterTypes.Length > 0)
×
94
        {
×
95
            member.Parameters = element.Elements("param")?
×
96
                .Select(e => Parameter.FromXml(e, parameterTypes[i++]))
×
97
                .ToArray();
×
98
        }
×
99

100
        var markdownMeta = element.Element("markdown-doc");
×
101

102
        member.IsPlugin = isPlugin;
×
103
        member.Parent = MarkdownMeta.FromXml(markdownMeta);
×
104
        member.MarkdownExamples = element.Elements("markdown-example")
×
105
            .Select(Example.FromXml)
×
106
            .ToArray();
×
107

108
        return member;
×
109
    }
×
110

111
    internal override string GetLinkMarkdown() => $"* [`{this.Name}` ({this.GetParametersSignature()})]({this.Parent.Path}{this.Name}.md)";
×
112

113
    internal override void FillTemplateReplacements(ref Dictionary<string, string> replacements)
114
    {
×
115
        base.FillTemplateReplacements(ref replacements);
×
116

117
        var parametersSignature = this.GetParametersSignature();
×
118
        var parameters = "";
×
119

120
        if (this.Parameters != null)
×
121
        {
×
122
            parameters = string.Join("\n", this.Parameters?
×
123
                .Select(p =>
×
124
                    $"* **{p.Name} (" + (p.IsOptional ? "Optional " : "") + $"```{p.GetTypeName(false)}```)** \n" +
×
125
                    $"\t{p.Description}\n\n"));
×
126
        }
×
127

128
        var examples = string.Join<Example>("\n\n", this.MarkdownExamples);
×
129

130
        replacements.Add("ParametersSignature", parametersSignature);
×
131
        replacements.Add("Parameters", parameters);
×
132

133
        if (this.ReturnType != null)
×
134
        {
×
135
            replacements.Add("ReturnType", $"```{this.ReturnType.GetTypeName()}```");
×
136
            replacements.Add("ReturnTypeDescription", $"{this.ReturnType.Description ?? ""}.");
×
137
        }
×
138
        else
139
        {
×
140
            replacements.Add("ReturnType", "");
×
141
        }
×
142

143
        replacements.Add("Examples", examples);
×
144
        replacements.Add("IsPlugin", IsPlugin ? "true" : "");
×
145
    }
×
146
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc