mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-31 21:03:43 +01:00
Revert "refactor(Dalamud): switch to file-scoped namespaces"
This reverts commit b5f34c3199.
This commit is contained in:
parent
d473826247
commit
1561fbac00
325 changed files with 45549 additions and 45209 deletions
|
|
@ -6,66 +6,67 @@ using Dalamud.Plugin.Internal.Types;
|
|||
using Dalamud.Utility;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Dalamud.Support;
|
||||
|
||||
/// <summary>
|
||||
/// Class responsible for sending feedback.
|
||||
/// </summary>
|
||||
internal static class BugBait
|
||||
namespace Dalamud.Support
|
||||
{
|
||||
private const string BugBaitUrl = "https://kiko.goats.dev/feedback";
|
||||
|
||||
/// <summary>
|
||||
/// Send feedback to Discord.
|
||||
/// Class responsible for sending feedback.
|
||||
/// </summary>
|
||||
/// <param name="plugin">The plugin to send feedback about.</param>
|
||||
/// <param name="content">The content of the feedback.</param>
|
||||
/// <param name="reporter">The reporter name.</param>
|
||||
/// <param name="includeException">Whether or not the most recent exception to occur should be included in the report.</param>
|
||||
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
|
||||
public static async Task SendFeedback(PluginManifest plugin, string content, string reporter, bool includeException)
|
||||
internal static class BugBait
|
||||
{
|
||||
if (content.IsNullOrWhitespace())
|
||||
return;
|
||||
private const string BugBaitUrl = "https://kiko.goats.dev/feedback";
|
||||
|
||||
var model = new FeedbackModel
|
||||
/// <summary>
|
||||
/// Send feedback to Discord.
|
||||
/// </summary>
|
||||
/// <param name="plugin">The plugin to send feedback about.</param>
|
||||
/// <param name="content">The content of the feedback.</param>
|
||||
/// <param name="reporter">The reporter name.</param>
|
||||
/// <param name="includeException">Whether or not the most recent exception to occur should be included in the report.</param>
|
||||
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
|
||||
public static async Task SendFeedback(PluginManifest plugin, string content, string reporter, bool includeException)
|
||||
{
|
||||
Content = content,
|
||||
Reporter = reporter,
|
||||
Name = plugin.InternalName,
|
||||
Version = plugin.AssemblyVersion.ToString(),
|
||||
DalamudHash = Util.GetGitHash(),
|
||||
};
|
||||
if (content.IsNullOrWhitespace())
|
||||
return;
|
||||
|
||||
if (includeException)
|
||||
{
|
||||
model.Exception = Troubleshooting.LastException == null ? "Was included, but none happened" : Troubleshooting.LastException?.ToString();
|
||||
var model = new FeedbackModel
|
||||
{
|
||||
Content = content,
|
||||
Reporter = reporter,
|
||||
Name = plugin.InternalName,
|
||||
Version = plugin.AssemblyVersion.ToString(),
|
||||
DalamudHash = Util.GetGitHash(),
|
||||
};
|
||||
|
||||
if (includeException)
|
||||
{
|
||||
model.Exception = Troubleshooting.LastException == null ? "Was included, but none happened" : Troubleshooting.LastException?.ToString();
|
||||
}
|
||||
|
||||
var postContent = new StringContent(JsonConvert.SerializeObject(model), Encoding.UTF8, "application/json");
|
||||
var response = await Util.HttpClient.PostAsync(BugBaitUrl, postContent);
|
||||
|
||||
response.EnsureSuccessStatusCode();
|
||||
}
|
||||
|
||||
var postContent = new StringContent(JsonConvert.SerializeObject(model), Encoding.UTF8, "application/json");
|
||||
var response = await Util.HttpClient.PostAsync(BugBaitUrl, postContent);
|
||||
private class FeedbackModel
|
||||
{
|
||||
[JsonProperty("content")]
|
||||
public string? Content { get; set; }
|
||||
|
||||
response.EnsureSuccessStatusCode();
|
||||
}
|
||||
[JsonProperty("name")]
|
||||
public string? Name { get; set; }
|
||||
|
||||
private class FeedbackModel
|
||||
{
|
||||
[JsonProperty("content")]
|
||||
public string? Content { get; set; }
|
||||
[JsonProperty("dhash")]
|
||||
public string? DalamudHash { get; set; }
|
||||
|
||||
[JsonProperty("name")]
|
||||
public string? Name { get; set; }
|
||||
[JsonProperty("version")]
|
||||
public string? Version { get; set; }
|
||||
|
||||
[JsonProperty("dhash")]
|
||||
public string? DalamudHash { get; set; }
|
||||
[JsonProperty("reporter")]
|
||||
public string? Reporter { get; set; }
|
||||
|
||||
[JsonProperty("version")]
|
||||
public string? Version { get; set; }
|
||||
|
||||
[JsonProperty("reporter")]
|
||||
public string? Reporter { get; set; }
|
||||
|
||||
[JsonProperty("exception")]
|
||||
public string? Exception { get; set; }
|
||||
[JsonProperty("exception")]
|
||||
public string? Exception { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using Dalamud.Configuration;
|
||||
using Dalamud.Configuration.Internal;
|
||||
using Dalamud.Interface.Internal;
|
||||
using Dalamud.Plugin.Internal;
|
||||
|
|
@ -11,109 +12,110 @@ using Dalamud.Utility;
|
|||
using Newtonsoft.Json;
|
||||
using Serilog;
|
||||
|
||||
namespace Dalamud.Support;
|
||||
|
||||
/// <summary>
|
||||
/// Class responsible for printing troubleshooting information to the log.
|
||||
/// </summary>
|
||||
public static class Troubleshooting
|
||||
namespace Dalamud.Support
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the most recent exception to occur.
|
||||
/// Class responsible for printing troubleshooting information to the log.
|
||||
/// </summary>
|
||||
public static Exception? LastException { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Log the last exception in a parseable format to serilog.
|
||||
/// </summary>
|
||||
/// <param name="exception">The exception to log.</param>
|
||||
/// <param name="context">Additional context.</param>
|
||||
public static void LogException(Exception exception, string context)
|
||||
public static class Troubleshooting
|
||||
{
|
||||
LastException = exception;
|
||||
/// <summary>
|
||||
/// Gets the most recent exception to occur.
|
||||
/// </summary>
|
||||
public static Exception? LastException { get; private set; }
|
||||
|
||||
try
|
||||
/// <summary>
|
||||
/// Log the last exception in a parseable format to serilog.
|
||||
/// </summary>
|
||||
/// <param name="exception">The exception to log.</param>
|
||||
/// <param name="context">Additional context.</param>
|
||||
public static void LogException(Exception exception, string context)
|
||||
{
|
||||
var payload = new ExceptionPayload
|
||||
LastException = exception;
|
||||
|
||||
try
|
||||
{
|
||||
Context = context,
|
||||
When = DateTime.Now,
|
||||
Info = exception.ToString(),
|
||||
};
|
||||
var payload = new ExceptionPayload
|
||||
{
|
||||
Context = context,
|
||||
When = DateTime.Now,
|
||||
Info = exception.ToString(),
|
||||
};
|
||||
|
||||
var encodedPayload = Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(payload)));
|
||||
Log.Information($"LASTEXCEPTION:{encodedPayload}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, "Could not print exception.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Log troubleshooting information in a parseable format to Serilog.
|
||||
/// </summary>
|
||||
internal static void LogTroubleshooting()
|
||||
{
|
||||
var startInfo = Service<DalamudStartInfo>.Get();
|
||||
var configuration = Service<DalamudConfiguration>.Get();
|
||||
var interfaceManager = Service<InterfaceManager>.GetNullable();
|
||||
var pluginManager = Service<PluginManager>.GetNullable();
|
||||
|
||||
try
|
||||
{
|
||||
var payload = new TroubleshootingPayload
|
||||
var encodedPayload = Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(payload)));
|
||||
Log.Information($"LASTEXCEPTION:{encodedPayload}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LoadedPlugins = pluginManager?.InstalledPlugins?.Select(x => x.Manifest)?.ToArray(),
|
||||
DalamudVersion = Util.AssemblyVersion,
|
||||
DalamudGitHash = Util.GetGitHash(),
|
||||
GameVersion = startInfo.GameVersion.ToString(),
|
||||
Language = startInfo.Language.ToString(),
|
||||
DoDalamudTest = configuration.DoDalamudTest,
|
||||
DoPluginTest = configuration.DoPluginTest,
|
||||
InterfaceLoaded = interfaceManager?.IsReady ?? false,
|
||||
ThirdRepo = configuration.ThirdRepoList,
|
||||
ForcedMinHook = EnvironmentConfiguration.DalamudForceMinHook,
|
||||
};
|
||||
|
||||
var encodedPayload = Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(payload)));
|
||||
Log.Information($"TROUBLESHOOTING:{encodedPayload}");
|
||||
Log.Error(ex, "Could not print exception.");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
/// <summary>
|
||||
/// Log troubleshooting information in a parseable format to Serilog.
|
||||
/// </summary>
|
||||
internal static void LogTroubleshooting()
|
||||
{
|
||||
Log.Error(ex, "Could not print troubleshooting.");
|
||||
var startInfo = Service<DalamudStartInfo>.Get();
|
||||
var configuration = Service<DalamudConfiguration>.Get();
|
||||
var interfaceManager = Service<InterfaceManager>.GetNullable();
|
||||
var pluginManager = Service<PluginManager>.GetNullable();
|
||||
|
||||
try
|
||||
{
|
||||
var payload = new TroubleshootingPayload
|
||||
{
|
||||
LoadedPlugins = pluginManager?.InstalledPlugins?.Select(x => x.Manifest)?.ToArray(),
|
||||
DalamudVersion = Util.AssemblyVersion,
|
||||
DalamudGitHash = Util.GetGitHash(),
|
||||
GameVersion = startInfo.GameVersion.ToString(),
|
||||
Language = startInfo.Language.ToString(),
|
||||
DoDalamudTest = configuration.DoDalamudTest,
|
||||
DoPluginTest = configuration.DoPluginTest,
|
||||
InterfaceLoaded = interfaceManager?.IsReady ?? false,
|
||||
ThirdRepo = configuration.ThirdRepoList,
|
||||
ForcedMinHook = EnvironmentConfiguration.DalamudForceMinHook,
|
||||
};
|
||||
|
||||
var encodedPayload = Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(payload)));
|
||||
Log.Information($"TROUBLESHOOTING:{encodedPayload}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, "Could not print troubleshooting.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class ExceptionPayload
|
||||
{
|
||||
public DateTime When { get; set; }
|
||||
private class ExceptionPayload
|
||||
{
|
||||
public DateTime When { get; set; }
|
||||
|
||||
public string Info { get; set; }
|
||||
public string Info { get; set; }
|
||||
|
||||
public string Context { get; set; }
|
||||
}
|
||||
public string Context { get; set; }
|
||||
}
|
||||
|
||||
private class TroubleshootingPayload
|
||||
{
|
||||
public PluginManifest[] LoadedPlugins { get; set; }
|
||||
private class TroubleshootingPayload
|
||||
{
|
||||
public PluginManifest[] LoadedPlugins { get; set; }
|
||||
|
||||
public string DalamudVersion { get; set; }
|
||||
public string DalamudVersion { get; set; }
|
||||
|
||||
public string DalamudGitHash { get; set; }
|
||||
public string DalamudGitHash { get; set; }
|
||||
|
||||
public string GameVersion { get; set; }
|
||||
public string GameVersion { get; set; }
|
||||
|
||||
public string Language { get; set; }
|
||||
public string Language { get; set; }
|
||||
|
||||
public bool DoDalamudTest { get; set; }
|
||||
public bool DoDalamudTest { get; set; }
|
||||
|
||||
public bool DoPluginTest { get; set; }
|
||||
public bool DoPluginTest { get; set; }
|
||||
|
||||
public bool InterfaceLoaded { get; set; }
|
||||
public bool InterfaceLoaded { get; set; }
|
||||
|
||||
public bool ForcedMinHook { get; set; }
|
||||
public bool ForcedMinHook { get; set; }
|
||||
|
||||
public List<ThirdPartyRepoSettings> ThirdRepo { get; set; }
|
||||
public List<ThirdPartyRepoSettings> ThirdRepo { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue