Skip to content

Merge generics support in mscorlib#245

Draft
josesimoes wants to merge 55 commits into
mainfrom
develop
Draft

Merge generics support in mscorlib#245
josesimoes wants to merge 55 commits into
mainfrom
develop

Conversation

@josesimoes

@josesimoes josesimoes commented Apr 29, 2025

Copy link
Copy Markdown
Member

Description

  • Merge with main.

Motivation and Context

  • Used for unit tests in interpreter.

How Has This Been Tested?

Screenshots

Types of changes

  • Improvement (non-breaking change that improves a feature, code or algorithm)
  • Bug fix (non-breaking change which fixes an issue with code or algorithm)
  • New feature (non-breaking change which adds functionality to code)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Config and build (change in the configuration and build system, has no impact on code or features)
  • Dependencies (update dependencies and changes associated, has no impact on code or features)
  • Unit Tests (add new Unit Test(s) or improved existing one(s), has no impact on code or features)
  • Documentation (changes or updates in the documentation, has no impact on code or features)

Checklist:

  • My code follows the code style of this project (only if there are changes in source code).
  • My changes require an update to the documentation (there are changes that require the docs website to be updated).
  • I have updated the documentation accordingly (the changes require an update on the docs in this repo).
  • I have read the CONTRIBUTING document.
  • I have tested everything locally and all new and existing tests passed (only if there are changes in source code).
  • I have added new tests to cover my changes.

- Publish to nuget now happens on build from develop branch too.
- Temporary disable trigger for tags.

***NO_CI***
- Fix parameter name.
- Add branch to publish nugets from.

***NO_CI***
@coderabbitai

coderabbitai Bot commented Apr 29, 2025

Copy link
Copy Markdown

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR introduces Span<T> and ReadOnlySpan<T> ref struct implementations with comprehensive test coverage, adds generic collection interfaces (ICollection<T>), enhances Guid with equality operators and CompareTo overloads, adds MemoryExtensions.CopyTo() for array-to-span operations, updates CI pipeline configuration for conditional release handling based on branch names, and refactors test infrastructure.

Changes

Cohort / File(s) Summary
CI/Pipeline Configuration
azure-pipelines.yml, azure-pipelines-templates/check-nf-interpreter-to-test.yml
Removed tag-based trigger filtering, added DOTNET_NOLOGO variable, introduced nanoFramework interpreter version checking template, updated class-lib build/publish parameters (unitTestRunsettings, skipNuGetCache, usePreviewBuild, baseBranchName), modified GitHub release condition to gate on branch name (main/develop) with changelog generation enabled.
Version and Build Configuration
version.json, local_clr.runsettings
Updated base version to semantic format with preview tag and height-based build number; extended public release branch patterns. Added new test run settings file configuring MaxCpuCount, TestSessionTimeout, TargetFramework (net48), and local CLR instance path with verbose adapter logging.
Documentation
.github/copilot-instructions.md
Added comprehensive Copilot usage guidance covering repository purpose, architectural constraints, build variants, structure, conventions, and contribution rules for nanoFramework CoreLibrary development.
Core Span/Memory Types
nanoFramework.CoreLibrary/System/Span.cs, nanoFramework.CoreLibrary/System/ReadOnlySpan.cs, nanoFramework.CoreLibrary/System/MemoryExtensions.cs
Implemented Span<T> and ReadOnlySpan<T> readonly ref structs with constructors, indexers, slicing, ToArray(), CopyTo() (extern internal calls), enumerators, and equality operators. Added MemoryExtensions.CopyTo<T>() extension method wrapping nullable arrays to ReadOnlySpan<T>.
Guid Enhancements
nanoFramework.CoreLibrary/System/Guid.cs
Added CompareTo(Guid) overload, Equals(Guid) overload, equality operators (==, !=), renamed TryParseGuidWithDashes() to TryParse(), initialized backing _data field inline with null-coalescing guards.
Generic Collection Interfaces
nanoFramework.CoreLibrary/System/Collections/Generic/ICollection.cs, nanoFramework.CoreLibrary/System/Collections/Generic/ICollectionDebugView.cs
Added new ICollection<T> interface extending IEnumerable<T> with Count, IsReadOnly properties and manipulation methods. Added internal ICollectionDebugView<T> debug helper class.
Array and Unsafe Helpers
nanoFramework.CoreLibrary/System/Array.cs, nanoFramework.CoreLibrary/System/Runtime/CompilerServices/Unsafe.cs
Added conditional Array.Empty<T>() method and SZArrayHelper class for reflection-gated generic operations. Introduced Unsafe.As<T>() intrinsic for ref struct casting under NANOCLR_REFLECTION.
String Type Updates
nanoFramework.CoreLibrary/System/String.cs
Standardized to C# string keyword across APIs, added nullable-aware signatures under NANOCLR_REFLECTION, replaced managed Format with extern internal-call, expanded Trim* method variants, updated exception construction in PadLeft/PadRight.
Assembly and Project Configuration
nanoFramework.CoreLibrary/System/AssemblyInfo.cs, nanoFramework.CoreLibrary/CoreLibrary.nfproj, Tests/NFUnitTestSystemLib/NFUnitTestSystemLib.nfproj, Tests/NFUnitTestTypes/NFUnitTestTypes.nfproj, Tests/TestFramework/TestFramework.nfproj, nanoFramework.TestFramework
Updated AssemblyNativeVersion, set C# LangVersion to 13.0, added new compile items for span/collection/memory implementations, removed Assert.Obsolete.cs from test framework, updated subproject commit.
Comprehensive Unit Tests
Tests/NFUnitTestSystemLib/UnitTestMemoryExtensions.cs, Tests/NFUnitTestTypes/UnitTestGuid.cs, Tests/NFUnitTestTypes/UnitTestsReadOnlySpanByte.cs, Tests/NFUnitTestTypes/UnitTestsSpanByte.cs, Tests/NFUnitTestSystemLib/UnitTestInitLocalTests.cs, Tests/NFUnitTestArithmetic/UnitTestFormat.cs
Added extensive test coverage for Span<T> and ReadOnlySpan<byte> behavior (constructors, indexing, slicing, copying, equality), Guid operations (comparison, equality, parsing, hashing), MemoryExtensions.CopyTo(). Refactored SpanByte tests to use Span<byte>, enhanced SystemType1_GetType_Test() with progress logging, updated exception expectations in format tests.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Merge generics support in mscorlib' is concise, descriptive, and clearly summarizes the main objective of the changeset—adding generics support to the core library. It is well under 50 characters (34 characters) and does not end with a period.
Description check ✅ Passed The PR description, while minimal, provides relevant context including motivation (generics support for unit tests in interpreter) and acknowledges this is a merge with main. It is related to the substantial changeset that adds generics infrastructure, span/memory types, and supporting features.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
azure-pipelines.yml (2)

59-60: Remove duplicate variable declaration & trailing spaces.

You’ve declared DOTNET_NOLOGO both globally (lines 36–37) and again under the Build_mscorlib job. This duplication is unnecessary and may lead to confusion. Also, YAMLlint flagged trailing spaces on line 60.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 60-60: trailing spaces

(trailing-spaces)


132-136: Consider adding the generics branch to release conditions.

You’ve broadened the GitHub release condition to run on main and develop. To stay consistent with the new publicReleaseRefSpec, you might also include generics here if you intend to create releases from that branch.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cca059e and e37e4b8.

⛔ Files ignored due to path filters (11)
  • .runsettings is excluded by none and included by none
  • Tests/NFUnitTestGC/TestGC.cs is excluded by none and included by none
  • Tests/NFUnitTestSystemLib/UnitTestGCTest.cs is excluded by none and included by none
  • Tests/NFUnitTestSystemLib/UnitTestInitLocalTests.cs is excluded by none and included by none
  • Tests/NFUnitTestSystemLib/UnitTestReflectionTypeTest.cs is excluded by none and included by none
  • Tests/UnitTestLauncher/UnitTestLauncher.nfproj is excluded by none and included by none
  • nanoFramework.CoreLibrary.nuspec is excluded by none and included by none
  • nanoFramework.CoreLibrary/System/AssemblyInfo.cs is excluded by none and included by none
  • nanoFramework.CoreLibrary/System/GC.cs is excluded by none and included by none
  • nanoFramework.CoreLibrary/System/Guid.cs is excluded by none and included by none
  • nanoFramework.TestFramework is excluded by none and included by none
📒 Files selected for processing (2)
  • azure-pipelines.yml (3 hunks)
  • version.json (2 hunks)
🧰 Additional context used
🪛 YAMLlint (1.35.1)
azure-pipelines.yml

[error] 60-60: trailing spaces

(trailing-spaces)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: nanoframework.CoreLibrary (Build_mscorlib)
  • GitHub Check: nanoframework.CoreLibrary (Build_mscorlib)
🔇 Additional comments (4)
version.json (2)

3-3: Approve semantic version update.

Updating the base version to "2.0.0-preview.{height}" correctly switches to semantic versioning with a preview suffix. This aligns with the pipeline change enabling preview builds.


14-14: Approve new public release branch pattern.

Adding ^refs/heads/generics$ to publicReleaseRefSpec ensures the newly merged “generics” branch is considered for public releases.

azure-pipelines.yml (2)

79-79: Verify template supports usePreviewBuild.

You’ve enabled usePreviewBuild: true in the class-lib-build-only.yml invocation. Please confirm that the template accepts and correctly propagates this parameter to invoke preview-mode builds as expected.


122-125: Ensure publish step aligns with new branches.

The class-lib-publish.yml template is now called with baseBranchName: 'develop'. Given that version.json includes a generics branch for public releases, please verify whether baseBranchName should dynamically reflect generics (or accept a list of branches) to fully support that branch.

@sonarqubecloud

Copy link
Copy Markdown

- Add target for .NET Framework v4.7.2
- Remove wrong space and update project entry.

***NO_CI***
@sonarqubecloud

Copy link
Copy Markdown

josesimoes added 2 commits May 6, 2026 22:07
- Fix logic to use build artifact in nf-interpreter pipeline when running unit tests.

***NO_CI***
@sonarqubecloud

Copy link
Copy Markdown

@sonarqubecloud

Copy link
Copy Markdown

1 similar comment
@sonarqubecloud

Copy link
Copy Markdown

@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants