perf: 支持.net9 (#21)

Co-authored-by: tk <fiyne1a@dingtalk.com>
This commit is contained in:
2024-11-25 17:01:15 +08:00
committed by GitHub
parent 7557cb0538
commit b32fe597dd
23 changed files with 250 additions and 165 deletions

View File

@ -1,6 +1,10 @@
$branch = $( git branch --show-current )
git add ../
./code.clean.ps1
$skipFormat = Read-Host "输入 n 跳过代码整理"
if ($skipFormat -ne "n")
{
./code.clean.ps1
}
git add ../
../node_modules/.bin/git-cz.ps1
git pull

View File

@ -1,7 +1,7 @@
cd ..
$types = @{
'1' = @('major', '主版本')
'2' = @('minor', '版本')
'2' = @('minor', '版本')
'3' = @('patch', '修订版本')
}
$prefix = ''
@ -10,19 +10,20 @@ while ($null -eq $types[$prefix])
$prefix = Read-Host "请选择版本类型`n" $( & { param($i) $i | ForEach-Object { "$_ : $( $types[$_][0] )$( $types[$_][1] )`n" } } $types.Keys | Sort-Object )
}
git checkout main
git pull
git branch -D release
git checkout -b release
./node_modules/.bin/standard-version -r $types[$prefix][0]
cd ./scripts
./code.clean.ps1
git commit --amend --no-edit -a
$tag = $(git describe --tags $(git rev-list --tags --max-count=1))
$tag = $( git describe --tags $( git rev-list --tags --max-count = 1 ) )
git tag -d $tag
git tag $tag
git push --tags origin release
Start-Process -FilePath "https://github.com/nsnail/NSExt/compare/main...release"
Write-Host "按『Enter』回到分支『Ctrl+C』退出"
Write-Host "按『Enter』回到tk分支『Ctrl+C』退出"
Pause
git checkout main
git pull
git branch -D release
git branch -D release
git branch -D tk
git checkout -b tk

View File

@ -0,0 +1,2 @@
git push origin :refs/tags/$(git tag -l "*-*")
git tag -d $(git tag -l "*-*")

View File

@ -0,0 +1,15 @@
using System.Text.RegularExpressions;
Console.WriteLine(string.Join(Environment.NewLine
, Regex
.Matches(File.ReadAllText(@"../assets/res/Ln.resx")
, "data name=\"(.*?)\"")
.Select(x => x.Groups[1].Value)
.Where(x => !Directory
.GetFiles(@"../src/backend/", "*.cs"
, new EnumerationOptions {
RecurseSubdirectories = true
})
.Select(File.ReadAllText)
.Any(y => y.Contains(x)))));
Console.ReadKey();

View File

@ -1,6 +1,7 @@
<#@ template language="C#" #>
<#@ assembly name="System.Xml" #>
<#@ output encoding="utf-8" extension="Designer.cs" #>
<#@ import namespace="System.Xml" #>
//------------------------------------------------------------------------------
// <auto-generated>
@ -27,8 +28,8 @@ namespace NSExt.Languages;
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[System.Diagnostics.DebuggerNonUserCode]
[System.Runtime.CompilerServices.CompilerGenerated]
[DebuggerNonUserCode]
[CompilerGenerated]
public sealed class Ln
{
private static ResourceManager _resourceMan;
@ -61,9 +62,9 @@ public sealed class Ln
[EditorBrowsable(EditorBrowsableState.Advanced)]
public static CultureInfo Culture { get; set; }
<#
var xml = new System.Xml.XmlDocument();
var xml = new XmlDocument();
xml.Load("../assets/res/Ln.resx");
foreach (System.Xml.XmlNode data in xml.SelectNodes("//root/data")!)
foreach (XmlNode data in xml.SelectNodes("//root/data")!)
{
#>
/// <summary>

View File

@ -1,5 +1,8 @@
<#@ template language="C#" #>
<#@ output encoding="utf-8" extension="resx" #>
<#@ import namespace="System.IO" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text.RegularExpressions" #>
<?xml version="1.0" encoding="utf-8"?>
<root>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
@ -25,15 +28,12 @@
</value>
</resheader>
<#
var regex = new System.Text.RegularExpressions.Regex(@"^\d", System.Text.RegularExpressions.RegexOptions.Compiled);
foreach (var file in System.IO.Directory.GetFiles("../assets/res/", "*.ln"))
var regex = new Regex(@"^\d", RegexOptions.Compiled);
foreach (var line in Directory.GetFiles("../assets/res/", "*.ln").SelectMany(x => File.ReadLines(x)).Distinct())
{
foreach (var line in System.IO.File.ReadLines(file))
{
#>
<data name="<#= regex.IsMatch(line) ? "_" : "" #><#= line #>" xml:space="preserve"><value><#= line #></value></data>
<#
}
}
#>
</root>

View File

@ -1,4 +1,4 @@
#r "nuget: NSExt, 1.1.0"
#r "nuget: NSExt, 2.2.0"
using NSExt.Extensions;
Console.WriteLine("请输入原始名称NSExt");

View File

@ -0,0 +1,42 @@
using System.Text.RegularExpressions;
string input = string.Empty;
while (!new[] { "1", "2" }.Contains(input))
{
Console.WriteLine("1.nuget 2.project");
input = Console.ReadLine();
}
var slnFile = Directory.GetFiles(@"../", "*.sln").First();
var csprojFiles = Directory.GetFiles(@"../src", "*.csproj", new EnumerationOptions { RecurseSubdirectories = true });
var slnContent = File.ReadAllText(slnFile);
if (input == "1")
{
slnContent = Regex.Replace(slnContent, "\\nProject\\((.*)#refs", "\n##Project($1#refs");
slnContent = Regex.Replace(slnContent, "\\nEndProject#refs", "\n##EndProject#refs");
foreach (Match m in Regex.Matches(slnContent, "\"(\\{[A-Z0-9]{8}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{12}\\})\"#refs"))
{
slnContent = slnContent.Replace($" {m.Groups[1].Value}.", $" ##{m.Groups[1].Value}.");
}
foreach (var csprojFile in csprojFiles)
{
var csprojContent = File.ReadAllText(csprojFile);
csprojContent = Regex.Replace(csprojContent," <ProjectReference(.*)Label=\"refs\"(.*)>", " <!--<ProjectReference$1Label=\"refs\"$2>-->");
csprojContent = Regex.Replace(csprojContent," <!--<PackageReference(.*)Label=\"refs\"(.*)>-->", " <PackageReference$1Label=\"refs\"$2>");
File.WriteAllText(csprojFile, csprojContent);
}
}
else
{
slnContent = Regex.Replace(slnContent, "##", "");
foreach (var csprojFile in csprojFiles)
{
var csprojContent = File.ReadAllText(csprojFile);
csprojContent = Regex.Replace(csprojContent," <!--<ProjectReference(.*)Label=\"refs\"(.*)>-->", " <ProjectReference$1Label=\"refs\"$2>");
csprojContent = Regex.Replace(csprojContent," <PackageReference(.*)Label=\"refs\"(.*)>", " <!--<PackageReference$1Label=\"refs\"$2>-->");
File.WriteAllText(csprojFile, csprojContent);
}
}
Console.WriteLine(slnContent);
File.WriteAllText(slnFile, slnContent);

View File

@ -8,12 +8,12 @@ content = Regex.Replace(
"Project\\(\"{2150E333-8FDC-42A3-9474-1A3956D46DE8}\"\\) = \"meta\", \"meta\", \"{5198A03D-0CAC-4828-A807-34A693F73859}\"(?:.|\n)*?EndProject",
$$"""
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "meta", "meta", "{5198A03D-0CAC-4828-A807-34A693F73859}"
{{'\t'}}ProjectSection(SolutionItems) = preProject
ProjectSection(SolutionItems) = preProject
{{string.Join('\n',
Directory.GetFiles(@"../", "*").Where(x => !x.EndsWith(".sln") && !x.EndsWith(".user"))
.Select(x=>$"\t\t{Path.GetFileName(x)} = {Path.GetFileName(x)}")
.Select(x=>$" {Path.GetFileName(x)} = {Path.GetFileName(x)}")
)}}
{{'\t'}}EndProject
EndProject
"""
);
@ -22,12 +22,12 @@ content = Regex.Replace(
"Project\\(\"{2150E333-8FDC-42A3-9474-1A3956D46DE8}\"\\) = \"workflows\", \"workflows\", \"{3C6F049E-3EE8-4D66-9AFF-E8A369032487}\"(?:.|\n)*?EndProject",
$$"""
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{3C6F049E-3EE8-4D66-9AFF-E8A369032487}"
{{'\t'}}ProjectSection(SolutionItems) = preProject
ProjectSection(SolutionItems) = preProject
{{string.Join('\n',
Directory.GetFiles(@"../.github/workflows", "*")
.Select(x=>$"\t\t{Path.GetFileName(x)} = .github/workflows/{Path.GetFileName(x)}")
.Select(x=>$" {Path.GetFileName(x)} = .github/workflows/{Path.GetFileName(x)}")
)}}
{{'\t'}}EndProject
EndProject
"""
);
@ -36,12 +36,12 @@ content = Regex.Replace(
"Project\\(\"{2150E333-8FDC-42A3-9474-1A3956D46DE8}\"\\) = \"scripts\", \"scripts\", \"{BB0B25C9-0901-4923-913F-00F9A6B352A5}\"(?:.|\n)*?EndProject",
$$"""
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "scripts", "scripts", "{BB0B25C9-0901-4923-913F-00F9A6B352A5}"
{{'\t'}}ProjectSection(SolutionItems) = preProject
ProjectSection(SolutionItems) = preProject
{{string.Join('\n',
Directory.GetFiles(@"../scripts", "*")
.Select(x=>$"\t\t{Path.GetFileName(x)} = scripts/{Path.GetFileName(x)}")
.Select(x=>$" {Path.GetFileName(x)} = scripts/{Path.GetFileName(x)}")
)}}
{{'\t'}}EndProject
EndProject
"""
);
@ -50,12 +50,12 @@ content = Regex.Replace(
"Project\\(\"{2150E333-8FDC-42A3-9474-1A3956D46DE8}\"\\) = \"build\", \"build\", \"{8E4C93BA-9493-4892-80C4-5E174C504829}\"(?:.|\n)*?EndProject",
$$"""
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{8E4C93BA-9493-4892-80C4-5E174C504829}"
{{'\t'}}ProjectSection(SolutionItems) = preProject
ProjectSection(SolutionItems) = preProject
{{string.Join('\n',
Directory.GetFiles(@"../build", "*")
.Select(x=>$"\t\t{Path.GetFileName(x)} = build/{Path.GetFileName(x)}")
.Select(x=>$" {Path.GetFileName(x)} = build/{Path.GetFileName(x)}")
)}}
{{'\t'}}EndProject
EndProject
"""
);