CodeMerge 1.0.0

dotnet add package CodeMerge --version 1.0.0
                    
NuGet\Install-Package CodeMerge -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CodeMerge" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CodeMerge" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="CodeMerge" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CodeMerge --version 1.0.0
                    
#r "nuget: CodeMerge, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package CodeMerge@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CodeMerge&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=CodeMerge&version=1.0.0
                    
Install as a Cake Tool

CodeMerge 编号合并引擎

目录结构

  • src/
    • Domain/ 核心领域模型与算法(编号解析、合并与格式化)
    • Benchmarks/ 基于 BenchmarkDotNet 的性能基准项目
  • tests/
    • CodeMerge.Tests/ 单元测试与边界测试(xUnit)
  • docs/
    • README.md 项目说明与快速开始

功能概述

  • 支持纯数字、数字-字母混合、含一个或多个“.”的分段编号
  • 连续性判定遵循题述 2.x 规则,保持原始顺序
  • 输出格式使用 ~ 连接连续段首尾,, 分隔非连续段,不引入空格

公共 API

string MergeCodes(IEnumerable<string> codes)
string MergeCodes(IEnumerable<string> codes, int prefixIgnoreLength)
IReadOnlyList<string> ExpandCodes(string mergedCodes)

位于命名空间 CodeMergeCodeMergeEngine 类型。

int GetNumericWidth(string value)
string FormatNumeric(string value, NumericFormattingOptions options, int? widthOverride = null)
string FormatNumericWithMap(string fieldKey, string value, FieldWidthMap map, NumericFormattingOptions options)

位于命名空间 CodeMergeNumericFormatter 类型。

逆操作用法示例

var original = new[] { "A1", "A2", "A3", "B1", "B3" };
var merged = CodeMergeEngine.MergeCodes(original);        // A1~3,B1,B3
var expanded = CodeMergeEngine.ExpandCodes(merged);       // A1,A2,A3,B1,B3

var grid = new[]
{
    "A1.B1","A1.B2","A1.B3",
    "A2.B1","A2.B2","A2.B3",
    "A3.B1","A3.B2","A3.B3"
};
var mergedGrid = CodeMergeEngine.MergeCodes(grid);        // A1~3.B1~3
var expandedGrid = CodeMergeEngine.ExpandCodes(mergedGrid);

ExpandCodes 会先按 , 拆分多个段,再对每个段内的 ~ 进行一维或多维数字区间还原,支持:

  • 纯数字区间:1~31,2,3
  • 前缀+数字区间:A01~03A01,A02,A03
  • 多维笛卡尔积:A1~3.B1~3A1.B1A3.B3 共 9 个编号

编译与运行

  • 还原与编译
dotnet restore
dotnet build -c Release CodeMerge.sln
  • 单元测试
dotnet test -c Release tests/CodeMerge.Tests/CodeMerge.Tests.csproj
  • 性能与内存诊断
dotnet run -c Release --project src/Benchmarks/CodeMerge.Benchmarks/CodeMerge.Benchmarks.csproj

所有项目的编译输出统一到 artifacts/ 目录,不污染源码树。

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net45 is compatible.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.5

    • No dependencies.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 73 2/20/2026