Skip to content
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

inline is not ignore as it may should be. #128

Closed
aloisdg opened this issue May 2, 2021 · 4 comments
Closed

inline is not ignore as it may should be. #128

aloisdg opened this issue May 2, 2021 · 4 comments
Labels
question Third party Problem lies in a consumed library which may or may not have a work-round

Comments

@aloisdg
Copy link

aloisdg commented May 2, 2021

Hello,

I may forgot something but I dont know why inline function is seen as not covered. Well, it is technically true because the function is inlined by the compiler. But this should not be seen as red, shouldn't it?

with inline

image

without inline

image

Cheers,

@SteveGilham
Copy link
Owner

SteveGilham commented May 2, 2021

This is an annoying, but expected phenomenon. When the F# compiler inlines a method, it compiles the code almost as if the inlined method had been copied into place in the call site at the source level. The "almost" is because even a multi-statement function being inlined (e.g. the built-in string function) will become part of the single statement including the call site.

In particular, there is no debug information pointing at the original location of the method; just the one very large statement each time it is invoked.

The workround, if you want that line to go green, is to do something like

    let
#if !DEBUG
         inline
#endif
                  internal selectNodes (node:XmlNode) name =

assuming coverage testing on the debug build.

@aloisdg aloisdg changed the title inline inline is not ignore as it may should be. May 2, 2021
@aloisdg
Copy link
Author

aloisdg commented May 2, 2021

This is a functional workaround I may use but I don't really like that an external tool alter like this the way I write a function. I will think about it. Thank you for the answer. I will close this issue for now. Have a nice weekend if it is the weekend wherever you are. :)

@aloisdg aloisdg closed this as completed May 2, 2021
@SteveGilham
Copy link
Owner

The real fix would require an F# compiler enhancement that would bring in the debug sequence point information from the source assembly where available (or, possibly, where available from the same assembly), which would also enable what is not currently possible -- stepping through an inlined function in the debugger.

@SteveGilham SteveGilham added question Third party Problem lies in a consumed library which may or may not have a work-round labels May 4, 2021
@SteveGilham
Copy link
Owner

Related -- dotnet/fsharp#9176

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Third party Problem lies in a consumed library which may or may not have a work-round
Projects
None yet
Development

No branches or pull requests

2 participants