Skip to content

Conversation

@christian289
Copy link
Contributor

개요

Rust 기반 Braillify 라이브러리의 .NET 바인딩을 추가합니다. FFI/P/Invoke를 통해 네이티브 Rust 라이브러리를 .NET에서 사용할 수 있습니다.

NuGet 패키지

패키지 설명 타겟 프레임워크
BraillifyNet 라이브러리 netstandard2.0, netcoreapp3.1, net5.0~net10.0
Braillify CLI 도구 net10.0

지원 플랫폼

  • .NET Standard 2.0
  • .NET Core 3.1
  • .NET 5.0, 6.0, 7.0, 8.0, 9.0, 10.0
  • .NET Framework 4.7.2 (테스트 지원)

주요 구현

프로젝트 구조

packages/dotnet/
├── Cargo.toml                # Rust FFI 크레이트 설정
├── src/lib.rs                # C ABI 노출 함수
├── Braillify.slnx            # .NET 10 솔루션 파일 (slnx 형식)
├── BraillifyNet/             # .NET 클래스 라이브러리
│   ├── Braillify.cs          # 공개 API (Encode, EncodeToUnicode, EncodeToBrailleFont)
│   ├── NativeMethods.cs      # P/Invoke 선언 (버전별 전처리)
│   ├── NativeLibraryLoader.cs # 플랫폼별 네이티브 라이브러리 로딩
│   └── BraillifyException.cs  # 예외 클래스
├── Braillify/                # CLI 도구
│   └── Program.cs            # System.CommandLine 기반 CLI
├── Braillify.Tests/          # xUnit 테스트 (멀티타겟팅)
└── Braillify.Tests.NetFramework/ # MSTest (.NET Framework 4.7.2)

버전별 P/Invoke 구현 차이

버전 P/Invoke 방식 포인터 타입 UTF-8 마샬링
.NET 7+ LibraryImport (소스 생성기) nint/nuint StringMarshalling.Utf8
.NET 5-6 DllImport nint/nuint LPUTF8Str
.NET Core 3.1 DllImport IntPtr/UIntPtr LPUTF8Str
.NET Standard 2.0 DllImport IntPtr/UIntPtr 수동 UTF-8 변환

네이티브 라이브러리 로딩

  • .NET Core 3.1+: NativeLibrary.SetDllImportResolver 사용
  • AppContext.BaseDirectory 사용 (NativeAOT 호환)
  • 런타임 식별자(RID) 기반 경로 탐색: runtimes/{rid}/native/{lib}

CLI 사용법

# 글로벌 설치
dotnet tool install -g Braillify

# 설치 없이 실행 (.NET 10+)
dnx braillify "안녕하세요"

# 텍스트 변환
braillify "안녕하세요"
# 출력: ⠣⠒⠉⠻⠚⠠⠝⠬

# 파이프 입력
echo "안녕하세요" | braillify

# REPL 모드
braillify

라이브러리 사용법

using Braillify;

// 텍스트를 점자 유니코드로 변환
string braille = Braillify.EncodeToUnicode("안녕하세요");
// 결과: "⠣⠒⠉⠻⠚⠠⠝⠬"

// 텍스트를 점자 바이트 배열로 변환
byte[] bytes = Braillify.Encode("안녕하세요");

// 텍스트를 점자 폰트 문자열로 변환
string font = Braillify.EncodeToBrailleFont("안녕하세요");

테스트 결과

모든 72개 테스트 통과 (8개 프레임워크 × 9개 테스트)

빌드 명령어

# 네이티브 라이브러리 빌드
cargo build --release -p dotnet

# .NET 패키지 빌드
cd packages/dotnet && dotnet build -c Release

# 테스트 실행
cd packages/dotnet && dotnet test

🤖 Generated with Claude Code

christian289 and others added 14 commits January 5, 2026 18:05
- C ABI 형태로 Rust Interface 노출 (packages/dotnet/src/lib.rs)
- lib.rs 파일을 .NET Class Library로 Import (packages/dotnet/Braillify/NativeMethods.cs)
- 멀티 타기팅 (여러 .NET 플랫폼 대상) 형태로 작성
- Xunit 유닛 테스트 작성 (.NET Core 3.1, .NET 5, .NET 6, .NET 7, .NET 8, .NET 9, .NET 10)
- .NET Standard 2.0은 .NET Framework 4.7.2 기반의 MSTest 사용
dnx로 실행할 CLI 프로젝트를 Braillify로 수정
Braillify를 Wrapping 하는 라이브러리는 Braillify.Net으로 수정
@codecov
Copy link

codecov bot commented Jan 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Contributor

Changepacks

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

해당 dll 파일은 gitignore 되어야 하는 것 아닌지 문의드립니다 (각 플랫폼 마다 별도로 생성되어야 하는 것으로 보입니다.)

Copy link
Contributor Author

@christian289 christian289 Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아하 그렇습니다. 테스트하다가 빼먹었나보네요 ㅎㅎ... 다시 업데이트 하겠습니다.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵, 감사합니다!

주신 구조를 기반으로 changepacks 가 C#을 지원하도록 업데이트 하여 매끄럽게 C#프로젝트도 배포가 될 수 있도록 하겠습니다.

기여 정말 감사드립니다.

각각의 OS + Architecture 별로 각각 빌드해서 이용해야 함.
@christian289 christian289 requested a review from owjs3901 January 12, 2026 14:34
@owjs3901 owjs3901 merged commit 3847b82 into dev-five-git:main Jan 13, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants