chore: convert Dalamud to file-scoped namespaces

This commit is contained in:
goat 2022-10-29 15:23:22 +02:00
parent b093323acc
commit 987ff8dc8f
No known key found for this signature in database
GPG key ID: 49E2AA8C6A76498B
368 changed files with 55081 additions and 55450 deletions

View file

@ -1,52 +1,51 @@
using System;
using System.Collections.Generic;
namespace Dalamud.Interface.Internal.Windows.PluginInstaller
namespace Dalamud.Interface.Internal.Windows.PluginInstaller;
/// <summary>
/// Class representing a Dalamud changelog.
/// </summary>
internal class DalamudChangelog
{
/// <summary>
/// Class representing a Dalamud changelog.
/// Gets the date of the version.
/// </summary>
internal class DalamudChangelog
public DateTime Date { get; init; }
/// <summary>
/// Gets the relevant version number.
/// </summary>
public string Version { get; init; }
/// <summary>
/// Gets the list of changes.
/// </summary>
public List<DalamudChangelogChange> Changes { get; init; }
/// <summary>
/// Class representing the relevant changes.
/// </summary>
public class DalamudChangelogChange
{
/// <summary>
/// Gets the date of the version.
/// Gets the commit message.
/// </summary>
public string Message { get; init; }
/// <summary>
/// Gets the commit author.
/// </summary>
public string Author { get; init; }
/// <summary>
/// Gets the commit reference SHA.
/// </summary>
public string Sha { get; init; }
/// <summary>
/// Gets the commit datetime.
/// </summary>
public DateTime Date { get; init; }
/// <summary>
/// Gets the relevant version number.
/// </summary>
public string Version { get; init; }
/// <summary>
/// Gets the list of changes.
/// </summary>
public List<DalamudChangelogChange> Changes { get; init; }
/// <summary>
/// Class representing the relevant changes.
/// </summary>
public class DalamudChangelogChange
{
/// <summary>
/// Gets the commit message.
/// </summary>
public string Message { get; init; }
/// <summary>
/// Gets the commit author.
/// </summary>
public string Author { get; init; }
/// <summary>
/// Gets the commit reference SHA.
/// </summary>
public string Sha { get; init; }
/// <summary>
/// Gets the commit datetime.
/// </summary>
public DateTime Date { get; init; }
}
}
}

View file

@ -1,47 +1,46 @@
using System;
namespace Dalamud.Interface.Internal.Windows.PluginInstaller
namespace Dalamud.Interface.Internal.Windows.PluginInstaller;
/// <summary>
/// Class representing a Dalamud changelog.
/// </summary>
internal class DalamudChangelogEntry : IChangelogEntry
{
private readonly DalamudChangelog changelog;
/// <summary>
/// Class representing a Dalamud changelog.
/// Initializes a new instance of the <see cref="DalamudChangelogEntry"/> class.
/// </summary>
internal class DalamudChangelogEntry : IChangelogEntry
/// <param name="changelog">The changelog.</param>
public DalamudChangelogEntry(DalamudChangelog changelog)
{
private readonly DalamudChangelog changelog;
this.changelog = changelog;
/// <summary>
/// Initializes a new instance of the <see cref="DalamudChangelogEntry"/> class.
/// </summary>
/// <param name="changelog">The changelog.</param>
public DalamudChangelogEntry(DalamudChangelog changelog)
var changelogText = string.Empty;
for (var i = 0; i < changelog.Changes.Count; i++)
{
this.changelog = changelog;
var change = changelog.Changes[i];
changelogText += $"{change.Message} (by {change.Author})";
var changelogText = string.Empty;
for (var i = 0; i < changelog.Changes.Count; i++)
if (i < changelog.Changes.Count - 1)
{
var change = changelog.Changes[i];
changelogText += $"{change.Message} (by {change.Author})";
if (i < changelog.Changes.Count - 1)
{
changelogText += Environment.NewLine;
}
changelogText += Environment.NewLine;
}
this.Text = changelogText;
}
/// <inheritdoc/>
public string Title => "Dalamud Core";
/// <inheritdoc/>
public string Version => this.changelog.Version;
/// <inheritdoc/>
public string Text { get; init; }
/// <inheritdoc/>
public DateTime Date => this.changelog.Date;
this.Text = changelogText;
}
/// <inheritdoc/>
public string Title => "Dalamud Core";
/// <inheritdoc/>
public string Version => this.changelog.Version;
/// <inheritdoc/>
public string Text { get; init; }
/// <inheritdoc/>
public DateTime Date => this.changelog.Date;
}

View file

@ -4,35 +4,34 @@ using System.Net.Http;
using System.Net.Http.Json;
using System.Threading.Tasks;
namespace Dalamud.Interface.Internal.Windows.PluginInstaller
namespace Dalamud.Interface.Internal.Windows.PluginInstaller;
/// <summary>
/// Class responsible for managing Dalamud changelogs.
/// </summary>
internal class DalamudChangelogManager : IDisposable
{
private const string ChangelogUrl = "https://kamori.goats.dev/Plugin/CoreChangelog";
private readonly HttpClient client = new();
/// <summary>
/// Class responsible for managing Dalamud changelogs.
/// Gets a list of all available changelogs.
/// </summary>
internal class DalamudChangelogManager : IDisposable
public IReadOnlyList<DalamudChangelog>? Changelogs { get; private set; }
/// <summary>
/// Reload the changelog list.
/// </summary>
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
public async Task ReloadChangelogAsync()
{
private const string ChangelogUrl = "https://kamori.goats.dev/Plugin/CoreChangelog";
this.Changelogs = await this.client.GetFromJsonAsync<List<DalamudChangelog>>(ChangelogUrl);
}
private readonly HttpClient client = new();
/// <summary>
/// Gets a list of all available changelogs.
/// </summary>
public IReadOnlyList<DalamudChangelog>? Changelogs { get; private set; }
/// <summary>
/// Reload the changelog list.
/// </summary>
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
public async Task ReloadChangelogAsync()
{
this.Changelogs = await this.client.GetFromJsonAsync<List<DalamudChangelog>>(ChangelogUrl);
}
/// <inheritdoc/>
public void Dispose()
{
this.client.Dispose();
}
/// <inheritdoc/>
public void Dispose()
{
this.client.Dispose();
}
}

View file

@ -1,30 +1,29 @@
using System;
namespace Dalamud.Interface.Internal.Windows.PluginInstaller
namespace Dalamud.Interface.Internal.Windows.PluginInstaller;
/// <summary>
/// Class representing a changelog entry.
/// </summary>
internal interface IChangelogEntry
{
/// <summary>
/// Class representing a changelog entry.
/// Gets the title of the entry.
/// </summary>
internal interface IChangelogEntry
{
/// <summary>
/// Gets the title of the entry.
/// </summary>
string Title { get; }
string Title { get; }
/// <summary>
/// Gets the version this entry applies to.
/// </summary>
string Version { get; }
/// <summary>
/// Gets the version this entry applies to.
/// </summary>
string Version { get; }
/// <summary>
/// Gets the text of the entry.
/// </summary>
string Text { get; }
/// <summary>
/// Gets the text of the entry.
/// </summary>
string Text { get; }
/// <summary>
/// Gets the date of the entry.
/// </summary>
DateTime Date { get; }
}
/// <summary>
/// Gets the date of the entry.
/// </summary>
DateTime Date { get; }
}

View file

@ -3,44 +3,43 @@
using Dalamud.Plugin.Internal.Types;
using Dalamud.Utility;
namespace Dalamud.Interface.Internal.Windows.PluginInstaller
namespace Dalamud.Interface.Internal.Windows.PluginInstaller;
/// <summary>
/// Class representing a plugin changelog.
/// </summary>
internal class PluginChangelogEntry : IChangelogEntry
{
/// <summary>
/// Class representing a plugin changelog.
/// Initializes a new instance of the <see cref="PluginChangelogEntry"/> class.
/// </summary>
internal class PluginChangelogEntry : IChangelogEntry
/// <param name="plugin">The plugin manifest.</param>
public PluginChangelogEntry(LocalPlugin plugin)
{
/// <summary>
/// Initializes a new instance of the <see cref="PluginChangelogEntry"/> class.
/// </summary>
/// <param name="plugin">The plugin manifest.</param>
public PluginChangelogEntry(LocalPlugin plugin)
{
this.Plugin = plugin;
this.Plugin = plugin;
if (plugin.Manifest.Changelog.IsNullOrEmpty())
throw new ArgumentException("Manifest has no changelog.");
if (plugin.Manifest.Changelog.IsNullOrEmpty())
throw new ArgumentException("Manifest has no changelog.");
var version = plugin.Manifest.EffectiveVersion;
var version = plugin.Manifest.EffectiveVersion;
this.Version = version!.ToString();
}
/// <summary>
/// Gets the respective plugin.
/// </summary>
public LocalPlugin Plugin { get; private set; }
/// <inheritdoc/>
public string Title => this.Plugin.Manifest.Name;
/// <inheritdoc/>
public string Version { get; init; }
/// <inheritdoc/>
public string Text => this.Plugin.Manifest.Changelog!;
/// <inheritdoc/>
public DateTime Date => DateTimeOffset.FromUnixTimeSeconds(this.Plugin.Manifest.LastUpdate).DateTime;
this.Version = version!.ToString();
}
/// <summary>
/// Gets the respective plugin.
/// </summary>
public LocalPlugin Plugin { get; private set; }
/// <inheritdoc/>
public string Title => this.Plugin.Manifest.Name;
/// <inheritdoc/>
public string Version { get; init; }
/// <inheritdoc/>
public string Text => this.Plugin.Manifest.Changelog!;
/// <inheritdoc/>
public DateTime Date => DateTimeOffset.FromUnixTimeSeconds(this.Plugin.Manifest.LastUpdate).DateTime;
}