Skip to content

Upgrade to .NET 8 and replace Thread.Abort with CancellationToken - #3

Open
dsn27 wants to merge 1 commit into
masterfrom
claude/migrate-dotnet8-pjpr6q
Open

Upgrade to .NET 8 and replace Thread.Abort with CancellationToken#3
dsn27 wants to merge 1 commit into
masterfrom
claude/migrate-dotnet8-pjpr6q

Conversation

@dsn27

@dsn27 dsn27 commented Jul 4, 2026

Copy link
Copy Markdown
Owner

Summary

This PR modernizes the CADability codebase by upgrading all projects to .NET 8.0 and replacing the deprecated Thread.Abort() pattern with CancellationTokenSource for graceful thread cancellation.

Key Changes

Threading Improvements (ConstrHatchInside.cs)

  • Replaced Thread.Abort() calls with CancellationTokenSource.Cancel() for safer thread termination
  • Added findShapeCts field to manage cancellation tokens
  • Removed ThreadAbortException catch block (no longer needed with cancellation tokens)
  • Simplified thread state checking logic by removing complex lock-based thread state validation
  • Updated thread creation to use modern lambda syntax instead of ThreadStart delegate

Framework Upgrades

  • CADability.csproj: Upgraded from netstandard2.0 to net8.0-windows
  • CADability.App.csproj: Upgraded from net48 to net8.0-windows
  • CADability.Forms.csproj: Upgraded from net48 to net8.0-windows
  • CADability.DebuggerVisualizers.csproj: Upgraded from net48 to net8.0-windows
  • CADability.Tests.csproj: Upgraded from net6.0-windows to net8.0-windows
  • netDxf.csproj: Simplified from multi-targeting (net48;net6.0) to single net8.0 target

Dependency Updates

  • Updated NuGet packages to .NET 8 compatible versions:
    • System.Drawing.Common: 6.0.0 → 8.0.0
    • System.Text.Encoding.CodePages: 6.0.0 → 8.0.0
    • System.Configuration.ConfigurationManager: Added (8.0.0)
    • Test framework packages updated to latest versions
  • Removed obsolete explicit assembly references (now implicit in .NET 8)
  • Removed language version constraints (LangVersion 7.3) and platform-specific settings

Project Configuration

  • Added EnableUnsafeBinaryFormatterSerialization property to all projects for backward compatibility
  • Cleaned up project files by removing redundant explicit references
  • Updated GitHub Actions workflow to use .NET 8.0.x SDK
  • Updated build output paths in documentation

Implementation Details

The thread cancellation refactoring maintains the same functional behavior while using modern .NET patterns. The CancellationTokenSource provides a cleaner, safer way to signal thread cancellation without the risks associated with Thread.Abort().

https://claude.ai/code/session_01X3aoafmguA8XPwQTqSGHzP

- Retarget all projects: netstandard2.0/net48/net6.0 → net8.0-windows (net8.0 for netDxf)
- Update System.Drawing.Common and System.Text.Encoding.CodePages to 8.0.0
- Add EnableUnsafeBinaryFormatterSerialization=true to all projects to keep existing ISerializable code working
- Add System.Configuration.ConfigurationManager 8.0.0 to .Forms and .App for Settings support
- Bump test framework packages (MSTest 3.1.1, TestSdk 17.8.0, coverlet 6.0.0)
- Remove all LangVersion 7.3 restrictions from configuration groups
- Remove legacy net48-style <Reference> items replaced by SDK auto-includes
- Fix hardcoded VS path and packages.config MathNet reference in DebuggerVisualizers
- Replace Thread.Abort() with CancellationTokenSource in ConstrHatchInside.cs
- Update CI workflow to .NET SDK 8.0.x and corrected output path
- Remove NET4X target from netDxf (net48 dropped)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X3aoafmguA8XPwQTqSGHzP
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