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

IDE0019 fails with disposable #34068

Closed
PhilPJL opened this issue Mar 13, 2019 · 1 comment
Closed

IDE0019 fails with disposable #34068

PhilPJL opened this issue Mar 13, 2019 · 1 comment
Labels
Area-IDE Bug IDE-CodeStyle Built-in analyzers, fixes, and refactorings Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented
Milestone

Comments

@PhilPJL
Copy link

PhilPJL commented Mar 13, 2019

Version Used:
VS2019 16 P4.2
Steps to Reproduce:

...

                using (var user = new UserPrincipal(context))
                {
                    user.SamAccountName = request.ClientUserName;

                    using (var searcher = new PrincipalSearcher())
                    {
                        searcher.QueryFilter = user;

// use pattern matching suggested here
                        using (var principal = searcher.FindOne() as UserPrincipal)
                        {
                            if (principal != null)
                            {
                                isValid = (principal.Enabled ?? false) && !principal.IsAccountLockedOut();
                            }
                        }
                    }
                }

Expected Behavior:
No suggestion?

Actual Behavior:
Uncompilable code

                    using ()
                    {
                        if (searcher.FindOne() is UserPrincipal principal)
                        {
                            isValid = (principal.Enabled ?? false) && !principal.IsAccountLockedOut();
                        }
                    }
@vatsalyaagrawal vatsalyaagrawal added Bug help wanted The issue is "up for grabs" - add a comment if you are interested in working on it Area-IDE IDE-CodeStyle Built-in analyzers, fixes, and refactorings labels Mar 15, 2019
@vatsalyaagrawal vatsalyaagrawal added this to the Backlog milestone Mar 15, 2019
@CyrusNajmabadi
Copy link
Member

Fixed with #48110

@sharwell sharwell modified the milestones: Backlog, 16.9.P1 Feb 8, 2022
@sharwell sharwell added Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented and removed help wanted The issue is "up for grabs" - add a comment if you are interested in working on it labels Feb 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Bug IDE-CodeStyle Built-in analyzers, fixes, and refactorings Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented
Projects
None yet
Development

No branches or pull requests

4 participants