Documentation Issue: ConditionalWeakTable<TKey,TValue> Class

Open Beginner friendly
#10,344 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
68/100
Issue type
Documentation
Clarity
Clearly specified
Activity status
Stale
Tech stack
csharp
Domain
documentation

Research direction

Open xml/System.Runtime.CompilerServices/ConditionalWeakTable`2.xml and locate the ConditionalWeakTable<TKey,TValue> example. Check the reported TryGetValue conversion and generic-type alternatives, then review how the example behaves in debug mode. Done means the example compiles and the documentation explains the debug-mode collection caveat if confirmed.

Written by the indexing model from the issue text.

Description

area-System.Runtime.CompilerServices Pri3 untriaged
Type of issue

Code doesn't work

Description
  1. The provided C# example fails to compile due to a conversion error. Example fixes:
    A) Replace cwt.TryGetValue(wr2.Target, out data) with cwt.TryGetValue((ManagedClass)wr2.Target, out data)
    B) Replace var cwt = new ConditionalWeakTable<ManagedClass, ClassData>(); with var cwt = new ConditionalWeakTable<object, ClassData>();

  2. Possibly it's worth adding a note that the example may fail to function in debug mode, since in-scope variables are ineligible for collection during debug.

Page URL

https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.conditionalweaktable-2?view=net-8.0&redirectedfrom=MSDN

Content source URL

https://github.com/dotnet/dotnet-api-docs/blob/main/xml/System.Runtime.CompilerServices/ConditionalWeakTable`2.xml

Document Version Independent Id

6a9b0e31-d0a6-c930-7959-20ac6f03ec4a

Article author

@dotnet-bot

Dominant language
C#
Stars
950
Forks
1.7k
Avg merge
3d 5h
Merged PRs (30d)
38

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dotnet/dotnet-api-docs

All issues in dotnet/dotnet-api-docs

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.