Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ReadOnlyDictionary and improve DebuggerAttributes #94581

Merged
merged 5 commits into from
Jan 26, 2024

Conversation

arturek
Copy link
Contributor

@arturek arturek commented Nov 9, 2023

  • Fix debugger type proxy attributes for Key and Value collections of ReadOnlyDictionary
  • Separate methods to test validity of the DebuggerTypeProxy attribute
    • ValidateDebuggerTypeProxyProperties - to verify debugger type proxy in most cases
    • CreateDebuggerTypeProxyWithNullArgument - to verify that the constructor of the debugger type proxy throws when its argument is null.
  • Simplify and make more uniform debugger type proxy tests

This is the first part of work on #94289

* Fix debugger type proxy attributes for Key and Value collections of ReadOnlyDictionary
* Separate methods to test validity of the DebuggerTypeProxy attribute
  * ValidateDebuggerTypeProxyProperties - to verify debugger type proxy in most cases
  * CreateDebuggerTypeProxyWithNullArgument - to verify that the constructor of the debugger type proxy throws when its argument is null.
* Simplify and make more uniform debugger type proxy tests

A prerequisite for dotnet#94289
@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label Nov 9, 2023
@ghost
Copy link

ghost commented Nov 9, 2023

Tagging subscribers to this area: @dotnet/area-system-collections
See info in area-owners.md if you want to be subscribed.

Issue Details
  • Fix debugger type proxy attributes for Key and Value collections of ReadOnlyDictionary
  • Separate methods to test validity of the DebuggerTypeProxy attribute
    • ValidateDebuggerTypeProxyProperties - to verify debugger type proxy in most cases
    • CreateDebuggerTypeProxyWithNullArgument - to verify that the constructor of the debugger type proxy throws when its argument is null.
  • Simplify and make more uniform debugger type proxy tests

This is the first part of work on #94289

Author: arturek
Assignees: -
Labels:

area-System.Collections, community-contribution

Milestone: -

}

Assert.True(threwNull);
TargetInvocationException tie = Assert.Throws<TargetInvocationException>(() => DebuggerAttributes.CreateDebuggerTypeProxyWithNullArgument(typeof(ArrayList)));
Copy link
Member

Choose a reason for hiding this comment

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

Just trying to undertand how non-generic collections are related to this change. Is it part of an infrastructural refactoring? Is ReadOnlyDictionary used under wraps somehow?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

While working on code that handles the creation of some debugger type proxies, I had to deal that the ValidateDebuggerTypeProxyProperties method, which accepted an instance of the class under test and its type. The parameters could conflict with each other. Usually this method was used in one of two ways: to validate an instance of the class under test, or to check if the constructor of a debug type proxy fails when executed with a null argument. This means that only one of these arguments (instance or type) should be used. I extracted the this second use case into the CreateDebuggerTypeProxyWithNullArgument method.

I replaced all uses of ValidateDebuggerTypeProxyProperties with a null instance argument with CreateDebuggerTypeProxyWithNullArgument (as seen above). In other references, I removed type arguments, so now the type is correctly determined based on the supplied instance. Both methods can be used to handle generic and non-generic classes.

This led to the Keys and Values classes of ReadOnlyDictionary, which were attributed with mismatched debugger type proxy class (Visual Studio silently ignored their type proxy attributes).

@arturek
Copy link
Contributor Author

arturek commented Dec 9, 2023

Hi @eiriktsarpalis, I have updated the code to fix an issue with the tests that I somehow overlooked earlier. The only failing test seems unrelated. I hope the PR can be committed now, so I can complete another one for immutable collections.

@eiriktsarpalis eiriktsarpalis self-assigned this Jan 16, 2024
Copy link
Member

@eiriktsarpalis eiriktsarpalis left a comment

Choose a reason for hiding this comment

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

Thanks!

@eiriktsarpalis eiriktsarpalis merged commit bcc1d3d into dotnet:main Jan 26, 2024
174 of 178 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Feb 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Collections community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants