@@ -658,6 +658,246 @@ let private rangeTests state =
658658 | MyModule.$<ParseInt>$ v -> v
659659 | _ -> 0
660660 """
661+ testCaseAsync " can get range of struct partial Active Pattern"
662+ <|
663+ // Struct partial active pattern: `(|ParseIntStruct|_|)` - returns ValueOption
664+ // These use ValueSome/ValueNone for better performance (no heap allocation)
665+ checkRanges
666+ server
667+ """
668+ module MyModule =
669+ let ($D<|Pa$0rseIntStruct|_|>D$) (input: string) =
670+ match System.Int32.TryParse input with
671+ | true, v -> ValueSome v
672+ | false, _ -> ValueNone
673+
674+ open MyModule
675+ let _ = ($<|ParseIntStruct|_|>$) "42"
676+ let _ = MyModule.($<|ParseIntStruct|_|>$) "42"
677+ let _ =
678+ match "42" with
679+ | ParseIntStruct v -> v
680+ | _ -> 0
681+ let _ =
682+ match "42" with
683+ | MyModule.ParseIntStruct v -> v
684+ | _ -> 0
685+ """
686+ testCaseAsync " can get range of struct partial Active Pattern case"
687+ <|
688+ // When clicking on the case name in a struct partial active pattern
689+ checkRanges
690+ server
691+ """
692+ module MyModule =
693+ let (|$D<ParseIntStruct>D$|_|) (input: string) =
694+ match System.Int32.TryParse input with
695+ | true, v -> ValueSome v
696+ | false, _ -> ValueNone
697+
698+ open MyModule
699+ let _ = (|ParseIntStruct|_|) "42"
700+ let _ = MyModule.(|ParseIntStruct|_|) "42"
701+ let _ =
702+ match "42" with
703+ | $<ParseInt$0Struct>$ v -> v
704+ | _ -> 0
705+ let _ =
706+ match "42" with
707+ | MyModule.$<ParseIntStruct>$ v -> v
708+ | _ -> 0
709+ """
710+ testCaseAsync " can get range of parameterized Active Pattern"
711+ <|
712+ // Parameterized active pattern: `(|DivisibleBy|_|) divisor value`
713+ // Takes an extra parameter before the input
714+ checkRanges
715+ server
716+ """
717+ module MyModule =
718+ let ($D<|Divi$0sibleBy|_|>D$) divisor value =
719+ if value % divisor = 0 then Some(value / divisor)
720+ else None
721+
722+ open MyModule
723+ let _ = ($<|DivisibleBy|_|>$) 3 9
724+ let _ = MyModule.($<|DivisibleBy|_|>$) 3 9
725+ let _ =
726+ match 9 with
727+ | DivisibleBy 3 q -> q
728+ | _ -> 0
729+ let _ =
730+ match 9 with
731+ | MyModule.DivisibleBy 3 q -> q
732+ | _ -> 0
733+ """
734+ testCaseAsync " can get range of parameterized Active Pattern case"
735+ <|
736+ // When clicking on the case name in a parameterized active pattern
737+ checkRanges
738+ server
739+ """
740+ module MyModule =
741+ let (|$D<DivisibleBy>D$|_|) divisor value =
742+ if value % divisor = 0 then Some(value / divisor)
743+ else None
744+
745+ open MyModule
746+ let _ = (|DivisibleBy|_|) 3 9
747+ let _ = MyModule.(|DivisibleBy|_|) 3 9
748+ let _ =
749+ match 9 with
750+ | $<Divisi$0bleBy>$ 3 q -> q
751+ | _ -> 0
752+ let _ =
753+ match 9 with
754+ | MyModule.$<DivisibleBy>$ 3 q -> q
755+ | _ -> 0
756+ """
757+ testCaseAsync " can get range of three-way total Active Pattern"
758+ <|
759+ // Three-way total active pattern: `(|Positive|Negative|Zero|)`
760+ checkRanges
761+ server
762+ """
763+ module MyModule =
764+ let ($D<|Posi$0tive|Negative|Zero|>D$) value =
765+ if value > 0 then Positive
766+ elif value < 0 then Negative
767+ else Zero
768+
769+ open MyModule
770+ let _ = ($<|Positive|Negative|Zero|>$) 42
771+ let _ = MyModule.($<|Positive|Negative|Zero|>$) 42
772+ let _ =
773+ match 42 with
774+ | Positive -> 1
775+ | Negative -> -1
776+ | Zero -> 0
777+ let _ =
778+ match 42 with
779+ | MyModule.Positive -> 1
780+ | MyModule.Negative -> -1
781+ | MyModule.Zero -> 0
782+ """
783+ testCaseAsync " can get range of three-way total Active Pattern case (Positive)"
784+ <|
785+ // When clicking on one case of a three-way total active pattern
786+ checkRanges
787+ server
788+ """
789+ module MyModule =
790+ let (|$D<Positive>D$|Negative|Zero|) value =
791+ if value > 0 then $<Positive>$
792+ elif value < 0 then Negative
793+ else Zero
794+
795+ open MyModule
796+ let _ = (|Positive|Negative|Zero|) 42
797+ let _ = MyModule.(|Positive|Negative|Zero|) 42
798+ let _ =
799+ match 42 with
800+ | $<Posi$0tive>$ -> 1
801+ | Negative -> -1
802+ | Zero -> 0
803+ let _ =
804+ match 42 with
805+ | MyModule.$<Positive>$ -> 1
806+ | MyModule.Negative -> -1
807+ | MyModule.Zero -> 0
808+ """
809+ testCaseAsync " can get range of NonEmpty partial Active Pattern"
810+ <|
811+ // Partial active pattern for non-empty strings
812+ checkRanges
813+ server
814+ """
815+ module MyModule =
816+ let ($D<|Non$0Empty|_|>D$) (input: string) =
817+ if System.String.IsNullOrWhiteSpace input then None
818+ else Some input
819+
820+ open MyModule
821+ let _ = ($<|NonEmpty|_|>$) "test"
822+ let _ = MyModule.($<|NonEmpty|_|>$) "test"
823+ let _ =
824+ match "test" with
825+ | NonEmpty s -> s
826+ | _ -> ""
827+ let _ =
828+ match "test" with
829+ | MyModule.NonEmpty s -> s
830+ | _ -> ""
831+ """
832+ testCaseAsync " can get range of NonEmpty partial Active Pattern case"
833+ <|
834+ checkRanges
835+ server
836+ """
837+ module MyModule =
838+ let (|$D<NonEmpty>D$|_|) (input: string) =
839+ if System.String.IsNullOrWhiteSpace input then None
840+ else Some input
841+
842+ open MyModule
843+ let _ = (|NonEmpty|_|) "test"
844+ let _ = MyModule.(|NonEmpty|_|) "test"
845+ let _ =
846+ match "test" with
847+ | $<Non$0Empty>$ s -> s
848+ | _ -> ""
849+ let _ =
850+ match "test" with
851+ | MyModule.$<NonEmpty>$ s -> s
852+ | _ -> ""
853+ """
854+ testCaseAsync " can get range of Regex parameterized Active Pattern"
855+ <|
856+ // Parameterized active pattern for regex matching
857+ checkRanges
858+ server
859+ """
860+ module MyModule =
861+ let ($D<|Re$0gex|_|>D$) pattern input =
862+ let m = System.Text.RegularExpressions.Regex.Match(input, pattern)
863+ if m.Success then Some m.Value
864+ else None
865+
866+ open MyModule
867+ let _ = ($<|Regex|_|>$) @"\d+" "abc123"
868+ let _ = MyModule.($<|Regex|_|>$) @"\d+" "abc123"
869+ let _ =
870+ match "abc123" with
871+ | Regex @"\d+" v -> v
872+ | _ -> ""
873+ let _ =
874+ match "abc123" with
875+ | MyModule.Regex @"\d+" v -> v
876+ | _ -> ""
877+ """
878+ testCaseAsync " can get range of Regex parameterized Active Pattern case"
879+ <|
880+ checkRanges
881+ server
882+ """
883+ module MyModule =
884+ let (|$D<Regex>D$|_|) pattern input =
885+ let m = System.Text.RegularExpressions.Regex.Match(input, pattern)
886+ if m.Success then Some m.Value
887+ else None
888+
889+ open MyModule
890+ let _ = (|Regex|_|) @"\d+" "abc123"
891+ let _ = MyModule.(|Regex|_|) @"\d+" "abc123"
892+ let _ =
893+ match "abc123" with
894+ | $<Re$0gex>$ @"\d+" v -> v
895+ | _ -> ""
896+ let _ =
897+ match "abc123" with
898+ | MyModule.$<Regex>$ @"\d+" v -> v
899+ | _ -> ""
900+ """
661901 testCaseAsync " can get range of type for static function call"
662902 <| checkRanges
663903 server
0 commit comments