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

Inline temporary variable messes up event registration for nested method #31300

Open
shyamnamboodiripad opened this issue Nov 21, 2018 · 1 comment

Comments

@shyamnamboodiripad
Copy link
Contributor

Version Used: 16.0.0 Int Preview [28320.52.d16.0]

Steps to Reproduce:

[TestClass]
class SettingsTests
{
    [TestMethod]
    public void Notifications()
    {
        var service = MockSettingsService.Instance;
        var notifications = new Queue<SettingChangedEventArgs>();
        void OnSettingChanged(object sender, SettingChangedEventArgs e) => notifications.Enqueue(e);
        service.SettingChanged += OnSettingChanged;
    }
}
  1. Trigger Inline temporary variable refactoring for local service

Expected Behavior:

var notifications = new Queue<SettingChangedEventArgs>();
void OnSettingChanged(object sender, SettingChangedEventArgs e) => notifications.Enqueue(e);
MockSettingsService.Instance.SettingChanged += OnSettingChanged;

Actual Behavior:

var notifications = new Queue<SettingChangedEventArgs>();
void OnSettingChanged(object sender, SettingChangedEventArgs e) => notifications.Enqueue(e);
MockSettingsService.Instance.SettingChanged += SettingsTests.OnSettingChanged;
@CyrusNajmabadi
Copy link
Member

Looks like a complexification/simplification issue.

@jinujoseph jinujoseph modified the milestones: 16.0.P2, 16.0 Dec 6, 2018
@jinujoseph jinujoseph modified the milestones: 16.0, 16.1 Jan 16, 2019
@jinujoseph jinujoseph modified the milestones: 16.1, Backlog Apr 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants