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

Always emit conditional attributes in FCS #6004

Merged
merged 6 commits into from
Jan 16, 2019

Conversation

auduchinok
Copy link
Member

Fixes #3890. We analyse conditionally erased attributes like CanBeNull or NotNull from JetBrains.Annotations package and need to see all attributes before erasure. Any objections to always doing it in the compiler service?

@KevinRansom
Copy link
Member

@auduchinok

#3890 indicated that there would be an option to enable or disable this. I'm not sure Don's comment covered the #if COMPILER_PUBLIC_API option.

Is it possible that tools developed with the FCS would want it both ways.
I.e, without the erased attribute and other FCS based tools would want it with the erased attribute?

Or is it possible, that there are no FCS scenarios that want the attributed erased?

Thanks

Kevin

@auduchinok
Copy link
Member Author

auduchinok commented Dec 13, 2018

@KevinRansom If I got it correctly Don didn't mind always emitting it in the service, which was another proposed way.

Another option is to make it always emit such attributes by adding COMPILER_PUBLIC_API condition directive to the code below so all attributes would be available for analysis by clients.

@auduchinok I'm fine with you adding this. A hidden command-line flag may be easiest to reduce plumbing, though I'm don't mind too much either way

I couldn't think of scenarios where FCS clients would want attributes erased. If there're such scenarios I'll change it to using an option.

@dsyme
Copy link
Contributor

dsyme commented Dec 13, 2018

I couldn't think of scenarios where FCS clients would want attributes erased. If there're such scenarios I'll change it to using an option.

I now think we should use a flag. FCS can be used for compilation and may in the future be used as the basis for implementing fsc.exe and fsi.exe

Copy link
Member

@KevinRansom KevinRansom left a comment

Choose a reason for hiding this comment

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

Can we add a switch pls.

@auduchinok
Copy link
Member Author

@dsyme @KevinRansom Sure, done.

@auduchinok auduchinok closed this Dec 22, 2018
@auduchinok auduchinok reopened this Dec 22, 2018
Copy link
Member

@KevinRansom KevinRansom left a comment

Choose a reason for hiding this comment

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

looks good.

Thank you

@TIHan
Copy link
Contributor

TIHan commented Dec 23, 2018

I kinda of don't like adding a specific switch for this. Why not have a switch to indicate we are running in tooling mode or compilation (fsc) mode?

/// The set of active conditional defines
conditionalDefines: string list
/// The set of active conditional defines. The value is None when conditional erasure is disabled in tooling.
conditionalDefines: string list option
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not a fan of list option types as I usually get confused by what it could mean. The comment does help though, so it's not a mystery. Though, I prefer another bool field honestly. What you think?

Copy link
Member

Choose a reason for hiding this comment

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

I think I'm okay with this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why are you ok with it? (Just curious because I'm on the fence).

The more I think about it, the more I really want a new bool field i.e isConditionalErasureEnabled : bool. Nothing can be clearer than that especially when it's used in code.

Using an option gives the field conditionalDefines more responsibility.

Copy link
Member Author

Choose a reason for hiding this comment

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

@TIHan On the other hand using option makes one aware of situation when there may be no conditional erasure unlike a separate field that one may be unaware of.

src/fsharp/CompileOptions.fs Outdated Show resolved Hide resolved
@KevinRansom KevinRansom merged commit 0bea66a into dotnet:master Jan 16, 2019
@auduchinok auduchinok deleted the always-emit-attrs-fcs branch July 24, 2024 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants