You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I propose adding a code fixer that can automatically introduce "this" variable if symbol is not recognized but there is an accessible instance method or property with the same name.
Consider this example from Playwright dotnet (note Page and Expect calls):
[Test]publicasyncTaskHomepageHasPlaywrightInTitleAndGetStartedLinkLinkingtoTheIntroPage(){awaitPage.GotoAsync("https://playwright.dev");// Expect a title "to contain" a substring.awaitExpect(Page).ToHaveTitleAsync(newRegex("Playwright"));// create a locatorvargetStarted=Page.GetByRole(AriaRole.Link,new(){Name="Get started"});// Expect an attribute "to be strictly equal" to the value.awaitExpect(getStarted).ToHaveAttributeAsync("href","/docs/intro");// Click the get started link.awaitgetStarted.ClickAsync();// Expects the URL to contain intro.awaitExpect(Page).ToHaveURLAsync(newRegex(".*intro"));}
Naive translation to F# resulted in this which is broken because Page and Expect are instance members. IDE doesn't really help here because it can't really find what an "Expect" is for example. There isn't such a type.
[<Test>]member_.HomepageHasPlaywrightInTitleAndGetStartedLinkLinkingtoTheIntroPage()=task{do! Page.GotoAsync("https://playwright.dev")// Expect a title "to contain" a substring.do! Expect(Page).ToHaveTitleAsync(new Regex("Playwright"))// create a locatorletgetStarted= Page.GetByRole(AriaRole.Link,new(){ Name ="Get started"})// Expect an attribute "to be strictly equal" to the value.do! Expect(getStarted).ToHaveAttributeAsync("href","/docs/intro")// Click the get started link.do! getStarted.ClickAsync()// Expects the URL to contain intro.do! Expect(Page).ToHaveURLAsync(new Regex(".*intro"))}
While correct one is this (note "this" binding). It would be nice to have a suggestion of introducing "this" binding if member exists in the current type.
[<Test>]memberthis.HomepageHasPlaywrightInTitleAndGetStartedLinkLinkingtoTheIntroPage()=task{let!_= this.Page.GotoAsync("https://playwright.dev")// Expect a title "to contain" a substring.do! this.Expect(this.Page).ToHaveTitleAsync(Regex("Playwright"))// create a locatorletgetStarted= this.Page.GetByRole(AriaRole.Link, PageGetByRoleOptions(Name ="Get started"))// Expect an attribute "to be strictly equal" to the value.do! this.Expect(getStarted).ToHaveAttributeAsync("href","/docs/intro")// Click the get started link.do! getStarted.ClickAsync()// Expects the URL to contain intro.do! this.Expect(this.Page).ToHaveURLAsync(Regex(".*intro"))}
P.S. it would be also nice to suggest "Introduce let! (var_name)" for cases when do! is used with non-unit expressions but that's another issue I guess,
The text was updated successfully, but these errors were encountered:
I propose adding a code fixer that can automatically introduce "this" variable if symbol is not recognized but there is an accessible instance method or property with the same name.
Consider this example from Playwright dotnet (note Page and Expect calls):
Naive translation to F# resulted in this which is broken because Page and Expect are instance members. IDE doesn't really help here because it can't really find what an "Expect" is for example. There isn't such a type.
While correct one is this (note "this" binding). It would be nice to have a suggestion of introducing "this" binding if member exists in the current type.
P.S. it would be also nice to suggest "Introduce let! (var_name)" for cases when do! is used with non-unit expressions but that's another issue I guess,
The text was updated successfully, but these errors were encountered: