返回提交历史
Modified
README.md
+14
-0
Modified
XFEExtension.NetCore.XFEConsole.Test/Program.cs
+15
-1
Added
XFEExtension.NetCore.XFEConsole/UseXFEConsoleAttribute.cs
+14
-0
Modified
XFEExtension.NetCore.XFEConsole/XFEConsole.cs
+23
-1
Modified
XFEExtension.NetCore.XFEConsole/XFEExtension.NetCore.XFEConsole.csproj
+3
-2
XFEstudio/XFEExtension.NetCore.XFEConsole
新增UseXFEConsole特性,用于添加至XUnit单元测试
198af62
代码差异
5 个文件
+69
-4
@@ -14,4 +14,18 @@ XFEConsole.ShowInDebug = true; // 是否在本地调试的Debug中展
14
14
XFEConsole.UseConsoleColor = true; // 使用控制台颜色,默认为 true
15
15
XFEConsole.ShowInLocalConsole = false; // 是否在本地控制台中显示,默认为 false
16
16
XFEConsole.AutoAnalyzeObject = true; // 是否自动解析对象,而非直接输出对象的.ToString()方法,默认为 true
17
```
18
19
## 配合XUnit测试框架
20
21
```csharp
22
class Program
23
{
24
[UseXFEConsole]
25
[SMTest]
26
static void TestMethod()
27
{
28
Console.WriteLine("使用XUnit框架输出");
29
}
30
}
17
31
```
@@ -1,4 +1,18 @@
1
1
using XFEExtension.NetCore.XFEConsole;
2
2
3
3
await XFEConsole.UseXFEConsole();
4
Console.WriteLine(XFEConsole.ClientList);
4
Console.WriteLine("准备测试...");
5
await Task.Delay(1000);
6
Console.WriteLine("3");
7
await Task.Delay(1000);
8
Console.WriteLine("2");
9
await Task.Delay(1000);
10
Console.WriteLine("1");
11
await Task.Delay(1000);
12
for (int i = 0; i < 10000; i++)
13
{
14
Console.WriteLine($"循环压力测试:{i}");
15
}
16
await Task.Delay(1000);
17
Console.WriteLine("测试结束");
18
await Task.Delay(3000);
@@ -0,0 +1,14 @@
1
namespace XFEExtension.NetCore.XFEConsole;
2
3
/// <summary>
4
/// 使用XFE控制台输出
5
/// </summary>
6
/// <param name="consolePort">控制台端口</param>
7
[AttributeUsage(AttributeTargets.Method)]
8
public class UseXFEConsoleAttribute(int consolePort = 3280) : Attribute
9
{
10
/// <summary>
11
/// 控制台端口
12
/// </summary>
13
public int ConsolePort { get; set; } = consolePort;
14
}
@@ -10,6 +10,10 @@ namespace XFEExtension.NetCore.XFEConsole;
10
10
/// </summary>
11
11
public class XFEConsole
12
12
{
13
/// <summary>
14
/// 当前控制台输出流
15
/// </summary>
16
public static XFEConsoleTextWriter? CurrentConsoleTextWriter { get; set; }
13
17
/// <summary>
14
18
/// 是否在本地调试的Debug中展示
15
19
/// </summary>
@@ -63,10 +67,28 @@ public class XFEConsole
63
67
/// <returns>是否连接成功</returns>
64
68
public static async Task<bool> UseXFEConsole(int port = 3280, string password = "") => await UseXFEConsole($"ws://localhost:{port}/", AppDomain.CurrentDomain.FriendlyName, Guid.NewGuid().ToString(), password);
65
69
/// <summary>
70
/// 停止XFE控制台
71
/// </summary>
72
/// <returns></returns>
73
public static async Task StopXFEConsole()
74
{
75
if (CurrentConsoleTextWriter is not null)
76
Console.SetOut(CurrentConsoleTextWriter.OriginalTextWriter);
77
foreach (var client in ClientList)
78
{
79
await client.Client.CloseCyberCommClient();
80
}
81
}
82
/// <summary>
66
83
/// 设置XFE控制台
67
84
/// </summary>
68
85
/// <returns></returns>
69
public static void SetConsoleOutput() => Console.SetOut(new XFEConsoleTextWriter(Console.Out));
86
public static void SetConsoleOutput()
87
{
88
CurrentConsoleTextWriter = new(Console.Out);
89
Console.SetOut(CurrentConsoleTextWriter);
90
}
91
70
92
/// <summary>
71
93
/// 连接XFE控制台
72
94
/// </summary>
@@ -4,7 +4,7 @@
4
4
<TargetFramework>net8.0</TargetFramework>
5
5
<ImplicitUsings>enable</ImplicitUsings>
6
6
<Nullable>enable</Nullable>
7
<Version>1.0.2</Version>
7
<Version>1.0.3</Version>
8
8
<Authors>XFEstudio</Authors>
9
9
<Company>寰宇朽力网络科技</Company>
10
10
<Description>XFEConsole是一个可以运行用户进行远程输出的调试辅助工具,需要配合XFE工具箱来使用,当然也可以根据本DLL内的架构搭建一个调试工具</Description>
@@ -14,10 +14,11 @@
14
14
<PackageReadmeFile>README.md</PackageReadmeFile>
15
15
<RepositoryUrl>https://github.com/XFEstudio/XFEExtension.NetCore.XFEConsole.git</RepositoryUrl>
16
16
<PackageTags>XFE;Console;Test;Out;Output;Remote;</PackageTags>
17
<PackageReleaseNotes>适配新版本</PackageReleaseNotes>
17
<PackageReleaseNotes>新增UseXFEConsole特性,用于添加至XUnit单元测试</PackageReleaseNotes>
18
18
<PackageLicenseFile>LICENSE</PackageLicenseFile>
19
19
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
20
20
<Title>XFEExtension.NetCore.XFEConsole</Title>
21
<GenerateDocumentationFile>True</GenerateDocumentationFile>
21
22
</PropertyGroup>
22
23
23
24
<ItemGroup>