// Detect It Easy: detection rule file

// Author: DosX
// E-Mail: collab@kay-software.ru
// GitHub: https://github.com/DosX-dev
// Telegram: @DosX_dev

function detect() {
    // https://github.com/0xd4d/dnlib
    if (PE.isNetObjectPresent("dnlib") && PE.isNetObjectPresent("ModuleDef"))
        _setResult("library", "dnlib", "", "");

    // https://www.mono-project.com/docs/tools+libraries/libraries/Mono.Cecil/
    if (PE.isNetObjectPresent("Mono.Cecil"))
        _setResult("library", "Mono.Cecil", "", "");

    // https://github.com/Washi1337/AsmResolver
    if (PE.isNetObjectPresent("AsmResolver"))
        _setResult("library", "AsmResolver", "", "");

    // https://learn.microsoft.com/en-us/dotnet/framework/reflection-and-codedom/using-the-codedom
    if (PE.isNetObjectPresent("System.CodeDom.Compiler")) { // Standard .NET library
        var languages = "";

        if (PE.isNetObjectPresent("CSharpCodeProvider"))
            languages = "C#";

        if (PE.isNetObjectPresent("VBCodeProvider"))
            languages += (languages ? " + " : "") + "VB.NET";

        if (PE.isNetObjectPresent("JScriptCodeProvider")) // Should check the relation to System.CodeDom......
            languages += (languages ? " + " : "") + "JScript";

        if (languages) {
            _setResult("library", "CodeDom Compiler", "", languages);
        }
    }
}