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

Move a few types related to pattern matching to be structs instead of classes. #68101

Merged
merged 5 commits into from
May 5, 2023

Conversation

CyrusNajmabadi
Copy link
Member

No description provided.

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner May 4, 2023 19:47
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels May 4, 2023
@@ -7,7 +7,7 @@

namespace Microsoft.CodeAnalysis.FindSymbols
{
internal class SearchQuery : IDisposable
internal readonly struct SearchQuery : IDisposable
Copy link
Member Author

Choose a reason for hiding this comment

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

was very close to being able to make the whole host of these into ref-struct types. But SearchQuery itself is captured into the heap through teh use of a "predicate" delegate it hands out to the compiler to do some work. So for now these have to be normal structs unfortunately.


return array;
}

public void Dispose()
{
if (_sourceLowerCaseCharacters == null)
throw new ObjectDisposedException(nameof(EditDistance));
Copy link
Member

@sharwell sharwell May 4, 2023

Choose a reason for hiding this comment

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

📝 I don't think this is working the way one would expect. This would only throw for the case of default(EditDistance), so InvalidOperationException might be more appropriate.

Copy link
Member Author

Choose a reason for hiding this comment

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

you are correct. will fix.

using System.Diagnostics;

namespace Roslyn.Utilities
{
internal class WordSimilarityChecker
internal struct WordSimilarityChecker : IDisposable
Copy link
Member

Choose a reason for hiding this comment

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

💡 Likely want either [NonCopyable] or readonly

Copy link
Member Author

Choose a reason for hiding this comment

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

yup. needs to be NonCopyable.

@CyrusNajmabadi CyrusNajmabadi merged commit 5fe099c into dotnet:main May 5, 2023
@ghost ghost added this to the Next milestone May 5, 2023
@CyrusNajmabadi CyrusNajmabadi deleted the simpleStructs branch May 5, 2023 16:25
@Cosifne Cosifne modified the milestones: Next, 17.7 P2 May 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants