Skip to content

Support CallerArgumentExpression #17519

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

Draft
wants to merge 93 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
9d3917a
Support CallerArgumentExpression
ijklam Jun 11, 2024
b698a3b
Merge remote-tracking branch 'upstream/main' into SupportCallerArgume…
ijklam Aug 11, 2024
dec3d3e
fix for fsi
ijklam Aug 11, 2024
e5d7763
revert unnecessary changes
ijklam Aug 11, 2024
5119bb6
Read and store file content before compilation
ijklam Aug 11, 2024
c914672
Change test; Add release note
ijklam Aug 11, 2024
5fe3495
Merge branch 'main' into SupportCallerArgumentExpression
ijklam Aug 11, 2024
536cf34
Add tests
ijklam Aug 11, 2024
b270e16
Merge branch 'SupportCallerArgumentExpression' of https://github.com/…
ijklam Aug 11, 2024
3fc4642
fix build; format
ijklam Aug 11, 2024
550daa4
Support `#line`
ijklam Aug 15, 2024
5cecb20
format
ijklam Aug 15, 2024
1b6cd56
support callee side optional arg
ijklam Aug 16, 2024
08d958b
Merge branch 'main' into SupportCallerArgumentExpression
ijklam Aug 16, 2024
68f2f61
format code
ijklam Aug 16, 2024
ec3b97f
Merge branch 'SupportCallerArgumentExpression' of https://github.com/…
ijklam Aug 16, 2024
7e93270
fix build
ijklam Aug 16, 2024
5790db9
fix test
ijklam Aug 16, 2024
46c4d46
try fix tests
ijklam Aug 25, 2024
8d792fa
fix build
ijklam Aug 25, 2024
65a4acc
test
ijklam Aug 25, 2024
1bdae47
Merge remote-tracking branch 'upstream/main' into SupportCallerArgume…
ijklam Sep 26, 2024
9e46116
Merge remote-tracking branch 'upstream/main' into SupportCallerArgume…
ijklam Feb 3, 2025
f379b7f
simplify code
ijklam Feb 3, 2025
843c71a
Merge branch 'main' into SupportCallerArgumentExpression
ijklam Feb 3, 2025
6d1a30d
simplify code; fix test
ijklam Feb 4, 2025
5f499a5
fix range
ijklam Feb 4, 2025
470b993
fix tests
ijklam Feb 4, 2025
477ed6e
fix tests
ijklam Feb 4, 2025
6fb6548
fix
ijklam Feb 4, 2025
c8ca45b
test
ijklam Feb 4, 2025
b5f22fb
test
ijklam Feb 4, 2025
271985b
test
ijklam Feb 4, 2025
31e7bb2
fix tests
ijklam Feb 26, 2025
d47ee7e
Merge remote-tracking branch 'upstream/main' into SupportCallerArgume…
ijklam Feb 26, 2025
424b83c
update baselines
ijklam Feb 26, 2025
77697cd
fix tests
ijklam Feb 26, 2025
1e43eff
test
ijklam Feb 26, 2025
2d38b2a
Merge remote-tracking branch 'upstream/main' into SupportCallerArgume…
ijklam Mar 11, 2025
52a0fc0
fix named arguments didn't trigger the feature
ijklam Mar 11, 2025
24a9494
baseline
ijklam Mar 11, 2025
935af15
Merge branch 'main' into SupportCallerArgumentExpression
ijklam Mar 11, 2025
31125f5
add new tests; improve err msg
ijklam Mar 13, 2025
49c46b1
adjust code; add and update tests
ijklam Mar 13, 2025
983f180
baseline
ijklam Mar 13, 2025
cf2085b
fix test
ijklam Mar 14, 2025
52a4d53
fmt
ijklam Mar 14, 2025
6e6dd39
Support for user defined CallerArgumentExpressionAttribute
ijklam Mar 15, 2025
9c5d917
replace the way get substring text
ijklam Mar 15, 2025
795c64a
test
ijklam Mar 15, 2025
98d8708
fix build
ijklam Mar 15, 2025
d68a6f7
fix test
ijklam Mar 15, 2025
9ac37e6
test
ijklam Mar 15, 2025
2cfba8d
Merge branch 'main' into SupportCallerArgumentExpression
psfinaki Mar 17, 2025
262ed24
revert the modify to `range`
ijklam Mar 17, 2025
9c24123
fix test and add new test
ijklam Mar 17, 2025
081a36b
Merge branch 'main' into SupportCallerArgumentExpression
ijklam Mar 17, 2025
1999506
Merge remote-tracking branch 'upstream/main' into SupportCallerArgume…
ijklam Mar 20, 2025
2e7121d
add a new test
ijklam Mar 20, 2025
fb8a3d0
add test
ijklam Mar 20, 2025
70f5630
change the position to get code file content
ijklam Mar 21, 2025
1cc4395
refractor
ijklam Mar 21, 2025
3c1deb4
new test
ijklam Mar 21, 2025
a5a4b8b
refactor
ijklam Mar 25, 2025
5cba8ca
fmt
ijklam Mar 25, 2025
0b02f01
Merge remote-tracking branch 'upstream/main' into SupportCallerArgume…
ijklam Mar 25, 2025
1258816
baseline; fix test
ijklam Mar 25, 2025
95a4930
fix test
ijklam Mar 25, 2025
c3baed5
Merge branch 'main' into SupportCallerArgumentExpression
ijklam Mar 25, 2025
5e1e27c
try fix cannot determine in C# method with non BCL attr
ijklam Mar 25, 2025
199d4b5
refactor
ijklam Mar 26, 2025
5e3e596
fix test
ijklam Mar 26, 2025
607f2d1
ilverify
ijklam Mar 26, 2025
1194359
Merge branch 'main' into SupportCallerArgumentExpression
ijklam Mar 26, 2025
f792bfa
Merge remote-tracking branch 'upstream/main' into SupportCallerArgume…
ijklam Apr 14, 2025
5aff4b2
fix build
ijklam Apr 14, 2025
173d748
Change the approach to implement the feature
ijklam Apr 19, 2025
499bb33
Merge branch 'main' into SupportCallerArgumentExpression
ijklam Apr 19, 2025
a215efa
change the way to pass the source text in
ijklam Apr 19, 2025
10b37d1
ilverify
ijklam Apr 19, 2025
f0da587
fmt
ijklam Apr 19, 2025
6d76a8e
make `cenv.Create(..., sourceText)` param not optional
ijklam Apr 22, 2025
be64605
Merge branch 'main' into SupportCallerArgumentExpression
ijklam Apr 28, 2025
874755a
fix no clear action; add OptionalArgument + Struct test
ijklam Apr 28, 2025
0ccbdf9
Merge remote-tracking branch 'upstream/main' into SupportCallerArgume…
ijklam Apr 28, 2025
5005a74
revert clear action
ijklam Apr 28, 2025
ec351c5
add a big file test
ijklam Apr 29, 2025
5b51706
Merge branch 'main' into SupportCallerArgumentExpression
ijklam May 5, 2025
09d200e
Merge remote-tracking branch 'upstream/main' into SupportCallerArgume…
ijklam May 15, 2025
ca912b5
fix build; fantomas
ijklam May 15, 2025
bf3841e
make the feature compatible with #line
ijklam May 15, 2025
462fd40
ilverify
ijklam May 15, 2025
d703b20
disable fGetOriginalRange
ijklam May 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
revert unnecessary changes
  • Loading branch information
ijklam committed Aug 11, 2024
commit e5d7763d46e8d174e08861ea2364042f7f66a71a
59 changes: 9 additions & 50 deletions src/Compiler/Service/ServiceStructure.fs
Original file line number Diff line number Diff line change
Expand Up @@ -839,40 +839,22 @@ module Structure =
elif line.StartsWithOrdinal("//") then Some SingleLine
else None

/// Determine if a line is //#region or //#endregion or else some thing
let (|BeginRegion|EndRegion|NotRegion|) =
let regex = System.Text.RegularExpressions.Regex("^\\s*//\\s*#(end)?region", System.Text.RegularExpressions.RegexOptions.Compiled)
fun (line: string) ->
let result = regex.Match(line)
match result.Success, result.Groups[1].Success with
| false, _ -> NotRegion
| true, false -> BeginRegion
| true, true -> EndRegion

let getCommentRanges trivia (lines: string[]) =
let rec loop (lastLineNum, currentComment, result as state) (lines: string list) lineNum =
match lines with
| [] -> state
| lineStr :: rest ->
match lineStr.TrimStart(), currentComment with
| (Comment SingleLine & (BeginRegion | EndRegion)), _ ->
let result' =
match currentComment with
| Some comment -> comment :: result
| None -> result
let comments = CommentList.New SingleLine (lineNum, lineStr)
loop (lineNum, Some comments, result') rest (lineNum + 1)
| Comment commentType, Some comment ->
let comments, result' =
match commentType, comment.Lines[comment.Lines.Count - 1] with
| SingleLine, (_, NotRegion)
| XmlDoc, _ when comment.Type = commentType && lineNum = lastLineNum + 1 ->
comment.Lines.Add(lineNum, lineStr)
currentComment, result
| _ ->
let comments = CommentList.New commentType (lineNum, lineStr)
Some comments, comment :: result
loop (lineNum, comments, result') rest (lineNum + 1)
loop
(if comment.Type = commentType && lineNum = lastLineNum + 1 then
comment.Lines.Add(lineNum, lineStr)
lineNum, currentComment, result
else
let comments = CommentList.New commentType (lineNum, lineStr)
lineNum, Some comments, comment :: result)
rest
(lineNum + 1)
| Comment commentType, None ->
let comments = CommentList.New commentType (lineNum, lineStr)
loop (lineNum, Some comments, result) rest (lineNum + 1)
Expand Down Expand Up @@ -911,29 +893,6 @@ module Structure =
})
|> acc.AddRange

let _, scopes =
comments
|> List.filter (fun comment -> comment.Type = SingleLine && comment.Lines.Count = 1)
|> List.fold (fun (stack, state) comment ->
match stack, comment.Lines[0] with
| _, (_, BeginRegion as startLine) -> startLine :: stack, state
| (startLine, startStr) :: rest, (endLine, (EndRegion as endStr)) ->
let startCol = startStr.IndexOf '/'
let endCol = endStr.TrimEnd().Length

let range = mkRange "" (mkPos (startLine + 1) startCol) (mkPos (endLine + 1) endCol)
let scope =
{
Scope = Scope.Comment
Collapse = Collapse.Same
Range = range
CollapseRange = range
}
rest, scope :: state
| _, (_, EndRegion as endLine) -> endLine :: stack, state
| _ -> stack, state) ([], [])
acc.AddRange scopes

for trivia in trivia do
match trivia with
| CommentTrivia.BlockComment m when m.StartLine <> m.EndLine ->
Expand Down
6 changes: 2 additions & 4 deletions src/Compiler/TypedTree/TcGlobals.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1083,7 +1083,6 @@ type TcGlobals(
// Adding an unnecessary "let" instead of inlining into a muiti-line pipelined compute-once "member val" that is too complex for @dsyme
let v_attribs_Unsupported = [
tryFindSysAttrib "System.Runtime.CompilerServices.ModuleInitializerAttribute"
// tryFindSysAttrib "System.Runtime.CompilerServices.CallerArgumentExpressionAttribute"
tryFindSysAttrib "System.Runtime.InteropServices.UnmanagedCallersOnlyAttribute"
tryFindSysAttrib "System.Runtime.CompilerServices.CompilerFeatureRequiredAttribute"
tryFindSysAttrib "System.Diagnostics.CodeAnalysis.SetsRequiredMembersAttribute"
Expand Down Expand Up @@ -1992,9 +1991,8 @@ type TcGlobals(
|> String.concat "\n"
| ValueNone ->
try
if FileSystem.IsInvalidPathShim m.FileName then
System.String.Empty
elif not (FileSystem.FileExistsShim m.FileName) then
if FileSystem.IsInvalidPathShim m.FileName ||
not (FileSystem.FileExistsShim m.FileName) then
System.String.Empty
else
FileSystem.OpenFileForReadShim(m.FileName).ReadLines()
Expand Down
2 changes: 0 additions & 2 deletions src/Compiler/Utilities/range.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@ type Range =

/// The range where all values are zero
static member Zero: range

member internal DebugCode: string

/// Represents a range within a file
and range = Range
Expand Down
Loading