Improve the naming. For example, don't use generic names for public-facing classes. For example "Component" is way too generic and it doesn't describe well what it is and can cause conflicts. A better name would be "ManialinkComponent" or "MlComponent" etc. Pretty much all classes under Lib/ has this issue.
Add doc comments
Improve namespace naming. Instead of just putting everything under Lib/ categorize them better, like Components/, Utils/, Templates/ etc.
public class ComponentProperty
{
public required string Type { get; }
public required string Name { get; }
public string? Default { get; }
}
The Helper.cs file seems to contain things that are not needed for the lib itself, but I guess its just for testing anyways?
Tests (use XUnit) should be added
Put interfaces in it's own namespace, it allows for separation of the implementation.
In general, you want to avoid optional parameters in .NET when creating libraries, and instead make overloads for the methods. It increases compatibility between API changes in the future. This is only really needed for public methods though.
I would probably move the regexes out of the methods and make them a static variable in the class so that they are compiled once instead of every time you call a method.
Use expression bodies where possible. For example in the example above.
Instead of this method: https://github.com/EvoTM/ManiaTemplates/blob/init/Lib/Snippet.cs#L58 Create an overload of ToString which accepts the parameter, not as an optional parameter. Then override the ToString() which calls the overload. This is the normal way you work with the .ToString method which is accessible in every object in .NET.
Create async versions of the library methods so that we can run the templates fully async in EvoSC#.
Looking over the code, here is what I think should be done in terms of cleaning up the code.
Refer to these docs for framework design guidelines, this is the common practice for all .NET libraries: https://learn.microsoft.com/en-us/dotnet/standard/design-guidelines/?redirectedfrom=MSDN
required
keyword. For example: https://github.com/EvoTM/ManiaTemplates/blob/init/Lib/ComponentProperty.cs#L9 a better and cleaner way to write this class would be:Helper.cs
file seems to contain things that are not needed for the lib itself, but I guess its just for testing anyways?StringBuilder
when concatenating strings. I see some places where this should be used. For example this: https://github.com/EvoTM/ManiaTemplates/blob/init/Lib/ComponentMarkdownGenerator.cs#L14StringBuilder
is very efficient and should almost always be used for generating string output of some sort..ToString()
: https://github.com/EvoTM/ManiaTemplates/blob/init/Lib/Snippet.cs#L55 For example:Make use of extension methods, for example this: https://github.com/EvoTM/ManiaTemplates/blob/init/Lib/Helper.cs#L25 can probably be re-written to this:
Then you would just need to call it like
node.UsesManialinkComponents(components)