Skip to content

Complete pattern matching: deconstruction and object-behavior tutorial - #56286

Draft
BillWagner wants to merge 2 commits into
dotnet:mainfrom
BillWagner:patterns-fundamentals
Draft

BillWagner wants to merge 2 commits into
dotnet:mainfrom
BillWagner:patterns-fundamentals

Conversation

@BillWagner

@BillWagner BillWagner commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

Closes #55928 (Everyday C# Phase F, PR 21).

  • Revise and move fundamentals/functional/deconstruct.md to fundamentals/patterns/deconstruct.md, covering tuples, records, custom Deconstruct methods/overloads, extension-method deconstruction, and mixed declared/var/discard deconstructions. Consolidate its samples into the shared patterns snippets project.
  • Migrate tutorials/patterns-objects.md (canal-lock state-machine tutorial) to fundamentals/tutorials/pattern-matching.md, with its own snippet project.
  • Relocate the pre-existing "type-driven and data-driven algorithms" (toll-calculator) tutorial to fundamentals/tutorials/advanced/pattern-matching.md to free the fundamentals/tutorials/pattern-matching.md slug for the migrated tutorial; update its snippet source paths and inbound links.
  • Update toc.yml: add the deconstruct article and both tutorials in their new locations; remove the now-empty Functional techniques node and the legacy top-level "Explore patterns in objects" entry.
  • Add/update redirects for every moved path, including the former functional/deconstruct.md and tutorials/patterns-objects.md locations, and the top-level docs/csharp/deconstruct.md redirect target.
  • Fix inbound links across the guide (types/tuples.md, discards.md, property-positional-patterns.md, language-reference pages, misc/ compiler-message pages, tour-of-csharp) that referenced the old functional/ and top-level tutorial paths.

Completes Pattern matching (§11) with no remaining planned core gaps; all moved paths have redirects, and no former functional/ deconstruction path breaks.


Internal previews

Toggle expand/collapse
File Preview link
.openpublishing.redirection.csharp.json Learn preview
docs/csharp/advanced-topics/expression-trees/index.md Learn preview
docs/csharp/fundamentals/expressions/operators.md Learn preview
docs/csharp/fundamentals/patterns/deconstruct.md Learn preview
docs/csharp/fundamentals/patterns/discards.md Learn preview
docs/csharp/fundamentals/patterns/property-positional-patterns.md Learn preview
docs/csharp/fundamentals/patterns/snippets/patterns/DeconstructSamples.cs Learn preview
docs/csharp/fundamentals/tutorials/advanced/pattern-matching.md Learn preview
docs/csharp/fundamentals/tutorials/pattern-matching.md Learn preview
docs/csharp/fundamentals/tutorials/snippets/pattern-matching-objects/CanalLock.cs Learn preview
docs/csharp/fundamentals/tutorials/snippets/pattern-matching-objects/InterimSteps.cs Learn preview
docs/csharp/fundamentals/tutorials/snippets/pattern-matching-objects/Program.cs Learn preview
docs/csharp/fundamentals/types/tuples.md Learn preview
docs/csharp/language-reference/builtin-types/value-tuples.md Learn preview
docs/csharp/language-reference/compiler-messages/deconstruction-errors.md Learn preview
docs/csharp/language-reference/compiler-messages/tuple-errors.md Learn preview
docs/csharp/language-reference/keywords/method-parameters.md Learn preview
docs/csharp/language-reference/operators/is.md Learn preview
docs/csharp/language-reference/operators/patterns.md Learn preview
docs/csharp/language-reference/operators/switch-expression.md Learn preview
docs/csharp/misc/cs0819.md Learn preview
docs/csharp/toc.yml Learn preview
docs/csharp/tour-of-csharp/tutorials/pattern-matching.md Learn preview

Build report

Closes dotnet#55928 (Everyday C# Phase F, PR 21).

- Revise and move fundamentals/functional/deconstruct.md to
  fundamentals/patterns/deconstruct.md, covering tuples, records,
  custom Deconstruct methods/overloads, extension-method
  deconstruction, and mixed declared/var/discard deconstructions.
  Consolidate its samples into the shared patterns snippets project.
- Migrate tutorials/patterns-objects.md (canal-lock state-machine
  tutorial) to fundamentals/tutorials/pattern-matching.md, with its
  own snippet project.
- Relocate the pre-existing "type-driven and data-driven algorithms"
  (toll-calculator) tutorial to
  fundamentals/tutorials/advanced/pattern-matching.md to free the
  fundamentals/tutorials/pattern-matching.md slug for the migrated
  tutorial; update its snippet source paths and inbound links.
- Update toc.yml: add the deconstruct article and both tutorials in
  their new locations; remove the now-empty Functional techniques
  node and the legacy top-level "Explore patterns in objects" entry.
- Add/update redirects for every moved path, including the former
  functional/deconstruct.md and tutorials/patterns-objects.md
  locations, and the top-level docs/csharp/deconstruct.md redirect
  target.
- Fix inbound links across the guide (types/tuples.md, discards.md,
  property-positional-patterns.md, language-reference pages, misc/
  compiler-message pages, tour-of-csharp) that referenced the old
  functional/ and top-level tutorial paths.

Completes Pattern matching (§11) with no remaining planned core
gaps; all moved paths have redirects, and no former functional/
deconstruction path breaks.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

The moved advanced tutorial contains broken relative references, and stale routing sends readers to the wrong tutorial.

Review effort: Balanced
Findings: 5 Medium severity

Open (5)
What changed in this PR

This PR reorganizes and completes the C# pattern-matching documentation.

Changes:

  • Adds expanded deconstruction guidance and consolidated samples.
  • Moves the canal-lock and toll-calculator tutorials into Fundamentals.
  • Updates navigation, links, redirects, and obsolete files.
File Description
.openpublishing.redirection.csharp.json Updates redirects for moved content.
docs/​csharp/​advanced-topics/​expression-trees/​index.md Updates the deconstruction link.
docs/​csharp/​fundamentals/​expressions/​operators.md Updates the deconstruction link.
docs/​csharp/​fundamentals/​functional/​deconstruct.md Removes the superseded article.
docs/​csharp/​fundamentals/​functional/​snippets/​deconstructing-tuples/​Program.cs Removes legacy snippet scaffolding.
docs/​csharp/​fundamentals/​functional/​snippets/​deconstructing-tuples/​class-discard1.cs Removes a legacy discard sample.
docs/​csharp/​fundamentals/​functional/​snippets/​deconstructing-tuples/​deconstruct-class1.cs Removes a legacy class sample.
docs/​csharp/​fundamentals/​functional/​snippets/​deconstructing-tuples/​deconstruct-class2.cs Removes legacy overload samples.
docs/​csharp/​fundamentals/​functional/​snippets/​deconstructing-tuples/​deconstruct-extension1.cs Removes a legacy extension sample.
docs/​csharp/​fundamentals/​functional/​snippets/​deconstructing-tuples/​deconstruct-kvp.cs Removes a legacy dictionary sample.
docs/​csharp/​fundamentals/​functional/​snippets/​deconstructing-tuples/​deconstruct-tuple1.cs Removes legacy tuple sample 1.
docs/​csharp/​fundamentals/​functional/​snippets/​deconstructing-tuples/​deconstruct-tuple2.cs Removes legacy tuple sample 2.
docs/​csharp/​fundamentals/​functional/​snippets/​deconstructing-tuples/​deconstruct-tuple3.cs Removes legacy tuple sample 3.
docs/​csharp/​fundamentals/​functional/​snippets/​deconstructing-tuples/​deconstruct-tuple4.cs Removes legacy tuple sample 4.
docs/​csharp/​fundamentals/​functional/​snippets/​deconstructing-tuples/​deconstruct-tuple5.cs Removes legacy tuple sample 5.
docs/​csharp/​fundamentals/​functional/​snippets/​deconstructing-tuples/​deconstruct-tuple6.cs Removes legacy tuple sample 6.
docs/​csharp/​fundamentals/​functional/​snippets/​deconstructing-tuples/​deconstruction.csproj Removes the legacy snippet project.
docs/​csharp/​fundamentals/​functional/​snippets/​deconstructing-tuples/​discard-tuple1.cs Removes the legacy tuple-discard sample.
docs/​csharp/​fundamentals/​patterns/​deconstruct.md Adds comprehensive deconstruction guidance.
docs/​csharp/​fundamentals/​patterns/​discards.md Updates deconstruction links.
docs/​csharp/​fundamentals/​patterns/​property-positional-patterns.md Updates deconstruction links.
docs/​csharp/​fundamentals/​patterns/​snippets/​patterns/​DeconstructSamples.cs Adds consolidated deconstruction samples.
docs/​csharp/​fundamentals/​patterns/​snippets/​patterns/​Program.cs Runs the new samples.
docs/​csharp/​fundamentals/​tutorials/​advanced/​pattern-matching.md Relocates the toll-calculator tutorial.
docs/​csharp/​fundamentals/​tutorials/​pattern-matching.md Adds the canal-lock tutorial.
docs/​csharp/​fundamentals/​tutorials/​snippets/​pattern-matching-objects/​CanalLock.cs Updates the sample namespace.
docs/​csharp/​fundamentals/​tutorials/​snippets/​pattern-matching-objects/​InterimSteps.cs Adds tutorial progression samples.
docs/​csharp/​fundamentals/​tutorials/​snippets/​pattern-matching-objects/​Program.cs Updates the sample namespace.
docs/​csharp/​fundamentals/​tutorials/​snippets/​pattern-matching-objects/​pattern-matching-objects.csproj Updates the root namespace.
docs/​csharp/​fundamentals/​types/​tuples.md Updates the deconstruction link.
docs/​csharp/​language-reference/​builtin-types/​value-tuples.md Updates the deconstruction link.
docs/​csharp/​language-reference/​compiler-messages/​deconstruction-errors.md Updates article links and anchors.
docs/​csharp/​language-reference/​compiler-messages/​tuple-errors.md Updates the deconstruction link.
docs/​csharp/​language-reference/​keywords/​method-parameters.md Updates the deconstruction link.
docs/​csharp/​language-reference/​operators/​is.md Updates the advanced tutorial link.
docs/​csharp/​language-reference/​operators/​patterns.md Updates tutorial and deconstruction links.
docs/​csharp/​language-reference/​operators/​switch-expression.md Updates the advanced tutorial link.
docs/​csharp/​misc/​cs0819.md Updates deconstruction links and anchors.
docs/​csharp/​toc.yml Reorganizes pattern articles and tutorials.
docs/​csharp/​tour-of-csharp/​tutorials/​pattern-matching.md Updates tutorial destinations.
docs/​csharp/​tutorials/​patterns-objects.md Removes the migrated tutorial.

Comment on lines +5638 to +5639
"source_path_from_root": "/docs/csharp/tutorials/patterns-objects.md",
"redirect_url": "/dotnet/csharp/fundamentals/tutorials/pattern-matching"
description: This advanced tutorial demonstrates how to use pattern matching techniques to create functionality using data and algorithms that are created separately.
ms.date: 02/25/2022
---
# Tutorial: Use pattern matching to build type-driven and data-driven algorithms
Comment thread docs/csharp/fundamentals/tutorials/advanced/pattern-matching.md Outdated
Comment thread docs/csharp/fundamentals/tutorials/advanced/pattern-matching.md Outdated
Comment thread docs/csharp/fundamentals/tutorials/advanced/pattern-matching.md Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.

Complete the Pattern matching section with deconstruction coverage and the introductory tutorial

2 participants