Skip to content

Conversation

ijklam
Copy link
Contributor

@ijklam ijklam commented Aug 11, 2024

Description

Implements fsharp/fslang-suggestions#966, #18489

RFC FS-1149-support-CallerArgumentExpression.md, FS-1332-assert-keyword-enhancement.md

图片

Checklist

  • Test cases added
  • Performance benchmarks added in case of performance changes
  • Release notes entry updated:

Copy link
Contributor

github-actions bot commented Aug 11, 2024

❗ Release notes required


✅ Found changes and release notes in following paths:

Change path Release notes path Description
LanguageFeatures.fsi docs/release-notes/.Language/preview.md

@ijklam
Copy link
Contributor Author

ijklam commented Aug 11, 2024

Here I encounter a problem about #line. For example, the code is saved in D:\Program.fs:

#1 "C:\\Program.fs"
System.ArgumentNullException.ThrowIfNullOrWhiteSpace("   ")  // will failed to build

// And more complicated case, repeat the file name and line number
#1 "C:\\Program.fs"
System.ArgumentNullException.ThrowIfNullOrWhiteSpace("   ")  // will failed to build

So here I want to get the original range instead of a range modified by #line . Is there anybody know how to do it?

| _ -> String.Empty
}

let getCodeText (m: range) =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder whether it would be possible to use ISourceText.GetSubTextString instead of all of this. I think the ISourceText for a given file will usually already be cached when this functionality is needed.

I think in theory the source text is available on cenv.tcSink.CurrentSink.Value.CurrentSourceText.Value, but maybe there's a better way to get it, or a better way to bring it in scope for this change.

Copy link
Contributor Author

@ijklam ijklam Aug 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

图片

It seems that this cannot work under dotnet fsi and under dotnet build. It is always None.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it would make sense to pass it in, then, as is done when checking format strings:

type FormatStringCheckContext =
{ SourceText: ISourceText
LineStartPositions: int[] }

let makeFmts (context: FormatStringCheckContext) (fragRanges: range list) (fmt: string) =
// Splits the string on interpolation holes based on fragment ranges.
// Returns a list of tuples in the form of: offset * fragment as a string * original range of the fragment
// where "offset" is the offset between beginning of the original range and where the string content begins
let numFrags = fragRanges.Length
let sourceText = context.SourceText

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it would make sense to pass it in, then, as is done when checking format strings:

I guess maybe that's the same source text as in the sink... But still, maybe there's somewhere else we could put it.

@ijklam ijklam changed the title Support CallerArgumentExpression (without #line) Support CallerArgumentExpression May 15, 2025
@ijklam
Copy link
Contributor Author

ijklam commented May 15, 2025

Turn this into draft until we make it compatible with the #lines.

@ijklam
Copy link
Contributor Author

ijklam commented Sep 4, 2025

@T-Gro Hi there, I cannot access the Azure to see the test result. Could you please grant me the permission?

The page said:

The selected user account does not exist in the tenant "Microsoft" and cannot access the application "499b84ac-1321-427f-aa17-267ca6975798" in that tenant. You need to add the account as an external user of the tenant first. Please use a different account.

@majocha
Copy link
Contributor

majocha commented Sep 4, 2025

@ijklam I see there are some timeouts in .Net Framework test runs, probably the cause is this #18875, so unrelated to your code. (threadpool starvation likely).

@ijklam ijklam marked this pull request as ready for review September 18, 2025 02:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: New
Development

Successfully merging this pull request may close these issues.

6 participants