Add C# port of the MassData Parameter API#41
Conversation
Agent-Logs-Url: https://github.com/NEVSTOP-LAB/CSM-MassData-Parameter-Support/sessions/c873d775-c857-4dc9-b4f2-35d49f003ed8 Co-authored-by: nevstop <8196752+nevstop@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds a .NET (C#) implementation of the CSM MassData Parameter Support API so .NET callers can exchange MassData reference strings with LabVIEW/C peers, with matching status semantics and a dedicated MSTest suite.
Changes:
- Introduces
Csm.MassDatalibrary (CsmMassData, status enum, exception type, operation struct) implementing the MassData ring-buffer encode/decode + parsing hardening. - Adds MSTest project/solution validating round-trips, error/status behavior, overwrite detection, and multi-thread stress.
- Updates repo plumbing: ignore
csharp/**in LabVIEW-focused workflows and add C# build artifacts to.gitignore.
Reviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| csharp/src/CsmMassData/CsmMassDataStatus.cs | Adds C-aligned status enum for .NET. |
| csharp/src/CsmMassData/CsmMassDataOperation.cs | Adds operation descriptor struct matching LabVIEW status cluster semantics. |
| csharp/src/CsmMassData/CsmMassDataException.cs | Adds exception type carrying CsmMassDataStatus. |
| csharp/src/CsmMassData/CsmMassData.csproj | Adds .NET 8 SDK-style library project. |
| csharp/src/CsmMassData/CsmMassData.cs | Core ring buffer, encoder/decoder, parser, and status APIs. |
| csharp/_test/vs/CsmMassData.Tests/MSTestSettings.cs | Disables parallel test execution at assembly level. |
| csharp/_test/vs/CsmMassData.Tests/CsmMassDataTests.cs | End-to-end MSTest coverage for the new API. |
| csharp/_test/vs/CsmMassData.Tests/CsmMassData.Tests.csproj | Adds MSTest project referencing the library. |
| csharp/_test/vs/CsmMassData.Tests.sln | Visual Studio solution for running the tests. |
| csharp/README.md | Documents layout, API mapping, usage, and test instructions. |
| .gitignore | Ignores C# build artifacts under csharp/. |
| .github/workflows/Check_Broken_VIs.yml | Prevents C#-only changes from triggering LabVIEW workflow. |
| .github/workflows/Build_VIPM_Library.yml | Prevents C#-only changes from triggering VIPM build workflow. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (dataType is not null) | ||
| { | ||
| // 数据类型不能包含会破坏引用字符串语法的字符。 | ||
| if (dataType.IndexOfAny(new[] { ';', '<', '>' }) >= 0) | ||
| { | ||
| throw new CsmMassDataException( | ||
| CsmMassDataStatus.InvalidArgument, | ||
| "dataType 中不允许出现 ';'、'<' 或 '>' 字符。"); | ||
| } |
There was a problem hiding this comment.
dataType.IndexOfAny 这里每次都会 new 一个 char[],在高频编码场景会产生不必要的分配。建议改为复用静态 readonly char[](或改为分别 Contains(';') / Contains('<') / Contains('>'))以避免每次调用分配。
| /// </remarks> | ||
| /// <param name="data">待保存的原始字节,<c>null</c> 视为空数据。</param> | ||
| /// <returns>MassData 参数字符串。</returns> | ||
| /// <exception cref="CsmMassDataException">编码过程中检测到错误时抛出。</exception> | ||
| public static string ConvertMassDataToArgument(ReadOnlySpan<byte> data) | ||
| => Encode(data, dataType: null); |
There was a problem hiding this comment.
该重载的参数类型是 ReadOnlySpan,在 C# 里不可能为 null,但 XML 注释仍写了“null 视为空数据”。建议把这条说明移到 byte[]? 重载,或改为说明空 Span 等价于空数据,以免误导调用方。
| /// 非空的数据类型字符串(例如 <c>"1D I32"</c>);不允许包含 | ||
| /// <c>';'</c>、<c>'<'</c> 或 <c>'>'</c>。 |
There was a problem hiding this comment.
这里的注释写“非空的数据类型字符串”,但实现仅拒绝 null/非法字符/过长,并未拒绝空字符串;C 端实现同样允许空字符串。建议要么在实现中显式拒绝空字符串,要么把注释改为“可为空字符串但不能为 null”,保证文档与行为一致。
| /// 非空的数据类型字符串(例如 <c>"1D I32"</c>);不允许包含 | |
| /// <c>';'</c>、<c>'<'</c> 或 <c>'>'</c>。 | |
| /// 可为空字符串但不能为 <c>null</c> 的数据类型字符串(例如 <c>"1D I32"</c>); | |
| /// 不允许包含 <c>';'</c>、<c>'<'</c> 或 <c>'>'</c>。 |
|
@copilot apply changes based on the comments in this thread |
Agent-Logs-Url: https://github.com/NEVSTOP-LAB/CSM-MassData-Parameter-Support/sessions/6d5c31c7-6690-46c5-8d1e-ba2a6dae5ac7 Co-authored-by: nevstop <8196752+nevstop@users.noreply.github.com>
已在 88d816d 中处理三处反馈:1) 将 |
|
@copilot 解决冲突的问题 |
…pport-to-massdata # Conflicts: # .gitignore Co-authored-by: nevstop <8196752+nevstop@users.noreply.github.com>
Provides a C# implementation of the CSM MassData Parameter Support API, on par with the C port from #40, so .NET callers can exchange MassData reference strings with LabVIEW / C peers.
Library (
csharp/src/CsmMassData/)CsmMassDatastatic class with the six methods matching the LabVIEW VIs / C functions (ConfigMassDataParameterCacheSize,ConvertMassDataToArgument[WithDataType],ConvertArgumentToMassData,MassDataDataTypeString,MassDataParameterStatus).CsmMassDataStatusenum mirrorscsm_massdata_status_tnumerically; errors surface asCsmMassDataExceptionexposing that status — idiomatic for .NET while keeping cross-language error parity.lock.ulongoverflow rejection onStart/Size,DataTypecharset validation (no;<>), no trailing junk allowed, and pre-add overflow check onstart + sizein the residency test.Tests (
csharp/_test/vs/)ulongoverflow), overwrite detection, cache-too-small, status reflection, forbidden-character rejection, empty payloads, and an 8-thread stress test..sln(# Visual Studio Version 18);[assembly: DoNotParallelize]since the API has process-wide shared state.Repo plumbing
csharp/**added topaths-ignoreinBuild_VIPM_Library.ymlandCheck_Broken_VIs.yml..gitignoreextended withcsharp/**/{bin,obj,Debug,Release,x64,x86,.vs}/and*.user/*.suo.Usage