Docfx not recognice class c#

47 views Asked by At

I have the following background service C# project directory that I want to document with Docfx.

Directories

Currently it documents the Worker.cs class, the classes that are in the "Objects" folder that are objects and the classes that are in the "Configuration" folder, specifically ConfigurationHelper which is an object of the xml file and IConfigurationHelper which is the interface.

The main problem with Docfx is that it does not recognize some of my c# classes which are the one in the "Functions" folder of which Utils.cs are my functions and also the Program.cs class, all these classes are ignored by Docfx.

Files not detect Docfx

I have a class called Program.cs that is in the same folder, but docfx doesn't recognize it.

This is my docfx.json file configuration

{
  "metadata": [
    {
      "src": [
        {
          "files": [
            "**/TestSharp.csproj",
            "**/Program.cs"
          ],
          "exclude": [
            "**/bin/**",
            "**/obj/**"
          ],
          "cwd": ".."
        }
      ],
      "dest": "obj/api"
    }
  ],
  "build": {
    "content": [
      {
        "files": [
          "**/*.{md,yml}"
        ],
        "exclude": [
          "_site/**"
        ]
      }
    ],
    "resource": [
      {
        "files": [
          "images/**"
        ]
      }
    ],
    "output": "_site",
    "template": [
      "default",
      "modern"
    ],
    "globalMetadata": {
      "_appName": "mysite",
      "_appTitle": "mysite",
      "_enableSearch": true,
      "pdf": true
    }
  },
  "metadataOptions": {
    "swagger": {
      "source": [
        {
          "files": [
            "**/TestSharp.csproj"
          ]
        }
      ],
      "dest": "swagger"
    }
  }
}

This is my Program.cs

using Serilog;
using System;
using System.IO;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Configuration;

/// <summary>
/// Main class of the application.
/// </summary>
public class Program
{
    /// <summary>
    /// Entry point of the application.
    /// </summary>
    /// <param name="args">Command line arguments.</param>
    public static void Main(string[] args)
    {
        string basedir = Path.Combine(Environment.CurrentDirectory, "Logs"); // Base directory for log files

        LoggerConfiguration(basedir);

        IConfigurationRoot _configuration = new ConfigurationBuilder()
            .SetBasePath(AppContext.BaseDirectory)
            .AddJsonFile(Path.Combine(AppContext.BaseDirectory, "appsettings.json"))
            .Build();

        IHost host = Host.CreateDefaultBuilder(args)
            .ConfigureServices(services =>
            {
                services.AddHostedService<TestSharp.Worker>(); // Add hosted service
                services.AddSingleton<TestSharp.Configuration.ConfigurationHelper, TestSharp.Configuration.ConfigurationHelper>();
                services.AddLogging(builder =>
                {
                    builder.SetMinimumLevel(LogLevel.Warning); // Set minimum log level to Warning
                    builder.AddConsole(); // Log to console
                });
            })
            .Build();

        host.Run();
    }

    /// <summary>
    /// Configures Serilog logger.
    /// </summary>
    /// <param name="basedir">Base directory for log files.</param>
    private static void LoggerConfiguration(string basedir) => Serilog.Log.Logger = new Serilog.LoggerConfiguration()
        .MinimumLevel.Debug() // Set minimum log level to Debug
        .WriteTo.Console(outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{NewLine}{Exception}") // Write to console
        .WriteTo.File($"{basedir}\\a2m2logger.txt", rollingInterval: Serilog.RollingInterval.Day, retainedFileTimeLimit: new TimeSpan(30, 0, 0, 0)) // Write to file
        .CreateLogger();
}

This is my Utils.cs

using System.Collections.Generic;
using Microsoft.Data.SqlClient;
using Microsoft.Data.Sqlite;
using Query.Models;
using Serilog;
using SFTPHelper;
using SharedVariables;
using System.Text.RegularExpressions;
using WatchDog.Configuration;
using WatchDog.Objects.JsonReport;
using WatchDog.Objects.StatusCompanies;
using WatchDog.Objects.StatusData;
using WatchDog.Objects.StatusSqlLite;

public class Utils
{

    Timer timer;
    private int _seconds;
    private string _dateTimmer;






/// <summary>
/// Starts and configures a timer, getting the current time.
/// </summary>
private void StartTimer()
{
    Console.CursorVisible = false;
    string date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff zzz");
    timer = new Timer(state => UpdateTimer(date), null, 0, 1000);
}

/// <summary>
/// Updates the timer and displays information on the console.
/// </summary>
/// <param name="dateTimer">Original date and time of the timer.</param>
private void UpdateTimer(string dateTimer)
{
    _seconds++;

    int hours = _seconds / 3600;
    int minutes = (_seconds % 3600) / 60;
    int remainingSeconds = _seconds % 60;

    _dateTimer = $"{hours:D2}:{minutes:D2}:{remainingSeconds:D2}";

    Console.CursorLeft = 0;
    Console.Write($"{dateTimer} [TMR] {hours:D2}:{minutes:D2}:{remainingSeconds:D2}");
}

/// <summary>
/// Stops the timer and releases associated resources.
/// </summary>
private void StopTimer()
{
    timer.Dispose();
    Console.CursorLeft = 0;
}

/// <summary>
/// Displays and writes the content of the LOG according to the process.
/// <remarks>
/// Allows modifying the importance type of the LOG content, whether it is information, warning, or error.
/// </remarks>
/// </summary>
/// <param name="text">Description text.</param>
/// <param name="process">Process name.</param>
/// <param name="type">Importance type.</param>
public void LogOut(string text, string process, int type)
{
    switch (type)
    {
        case 0:
            Log.Information($"[{process}] {text}");
            break;
        case 1:
            Log.Warning($"[{process}] {text}");
            break;
        case 2:
            Log.Error($"[{process}] {text}");
            break;
    }
}



}


I would like to know why Docfx does not take these files or if it is a configuration problem with the docfx.json file. I need Docfx to read Utils.cs and Program.cs comments.

0

There are 0 answers