Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit23d00fd

Browse files
committed
add tests for interaction with C#-style extension members
1 parent0a30282 commit23d00fd

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

‎tests/fsharp/core/quotes/test.fsx‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2497,6 +2497,7 @@ module TestAutoQuoteAtStaticMethodCalls =
24972497

24982498
moduleTestAutoQuoteAtInstanceMethodCalls=
24992499
openMicrosoft.FSharp.Quotations
2500+
openSystem.Runtime.CompilerServices
25002501

25012502

25022503
typeC()=
@@ -2528,7 +2529,32 @@ module TestAutoQuoteAtInstanceMethodCalls =
25282529
member__.PlotEval([<ReflectedDefinition(true)>]x:Expr<'T>)=
25292530
sprintf"%A" x|> cleanup
25302531

2532+
override__.ToString()="C"
25312533

2534+
[<Extension>]
2535+
moduleCSharpStyleExtensionMember=
2536+
letcleanup(s:string)= s.Replace("","").Replace("\n","").Replace("\r","")
2537+
[<Extension>]
2538+
typeCExtMem()=
2539+
[<Extension>]
2540+
static memberPlotCSharpStyleExtMem(this:C,[<ReflectedDefinition>]x:Expr<'T>)=
2541+
sprintf"%A" x|> cleanup
2542+
2543+
// Adding 'ReflectedDefinition' to an argument that doesn't have type Expr<'T> is ignored (no error or warning is given at declaration or use)
2544+
[<Extension>]
2545+
static memberPlotCSharpStyleExtMemNoExpr(this:C,[<ReflectedDefinition>]x:'T)=
2546+
sprintf"%A" x|> cleanup
2547+
2548+
// Adding 'ReflectedDefinition' to the 'this' argument of a C#-style extension member is ignored.
2549+
//
2550+
//[<Extension>]
2551+
//static member PlotCSharpStyleExtMemWithReflectedThis ([<ReflectedDefinition>] this: Expr<C>, [<ReflectedDefinition>] x: Expr<'T>) =
2552+
// sprintf "%A" (this, x) |> cleanup
2553+
[<Extension>]
2554+
static memberPlotCSharpStyleExtMemWithIgnoredReflectedThis([<ReflectedDefinition>]this:C,[<ReflectedDefinition>]x:Expr<'T>)=
2555+
sprintf"%A"(this, x)|> cleanup
2556+
2557+
openCSharpStyleExtensionMember
25322558
letshouldEqual id x y= check id y x
25332559
letx=1
25342560
lety=1
@@ -2579,6 +2605,12 @@ module TestAutoQuoteAtInstanceMethodCalls =
25792605

25802606
c.PlotEval(xb&& yb|| zb)|> shouldEqual"testd109712""WithValue(true,IfThenElse(IfThenElse(PropertyGet(None,xb,[]),PropertyGet(None,yb,[]),Value(false)),Value(true),ValueWithName(true,zb)))"
25812607

2608+
c.PlotCSharpStyleExtMem(xb&& yb|| zb)|> shouldEqual"testd109713""IfThenElse(IfThenElse(PropertyGet(None,xb,[]),PropertyGet(None,yb,[]),Value(false)),Value(true),ValueWithName(true,zb))"
2609+
2610+
c.PlotCSharpStyleExtMemNoExpr(xb&& yb|| zb)|> shouldEqual"testdoqhwm""true"
2611+
2612+
c.PlotCSharpStyleExtMemWithIgnoredReflectedThis(xb&& yb|| zb)|> shouldEqual"testd109714""(C,IfThenElse(IfThenElse(PropertyGet(None,xb,[]),PropertyGet(None,yb,[]),Value(false)),Value(true),ValueWithName(true,zb)))"
2613+
25822614
testItAll()
25832615

25842616
letaa=

‎tests/test.lst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Core06fsharp\core\queriesOverIQueryable
6666
Core06..\testsprivate\fsharp\core\queriesOverIQueryableLinqToEntities
6767
Core06..\testsprivate\fsharp\core\queriesOverIQueryableLinqToSql
6868
Core06fsharp\core\queriesOverOData
69-
Core06fsharp\core\quotes
69+
Core06,Quotationsfsharp\core\quotes
7070
Core06fsharp\core\quotesDebugInfo
7171
Core06fsharp\core\quotesInMultipleModules
7272
Core07fsharp\core\reflect

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp