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

[WIP] add F# WriteCodeFragment #2132

Closed
wants to merge 3 commits into from

Conversation

enricosada
Copy link

ref dotnet/netcorecli-fsc#93

to generate the assemblyinfo.fs from fsproj properties.

@KevinRansom the plan is to do it like c# does for coreclr (where codedom doesnt exists anyway), like here in src/Tasks/WriteCodeFragment.cs#L294-L313

/cc @rainersigwald

@AndyGerlicher
Copy link
Contributor

Thanks for opening a PR. Unfortunately we've already closed a similar PR (#2058) after expressing concerns that we would not like to have this logic in MSBuild. If you think this is not correct please open an issue to discuss.

@enricosada
Copy link
Author

@AndyGerlicher while long term this is not the best place, atm the dotnet/sdk use the WriteCodeFragment in the language agnostic Microsoft.NET.GenerateAssemblyInfo.targets#L93-L96.

So maybe is possibile to make a special case for F# in dotnet/sdk, but msbuild contains both c# and VB atm, so may make sense to leave it there and add F#, to make it work for sdk 2.0?

@AndyGerlicher i need to open an issue to discuss, or can be discussed there? /cc @KevinRansom @cartermp

@enricosada
Copy link
Author

Adding @dsplaisted @eerhardt for an hint about this, because dotnet/sdk is using the WriteCodeFragment in the language agnostic Microsoft.NET.GenerateAssemblyInfo.targets#L93-L96.

F# now is not supported in WriteCodeFragment, so the file is not generated.

Dunno if there is a better place to discuss, but pratically all the code needed is already there (i just need to add more unit tests, atm is just one), so maybe easier to see on what adding this mean for msbuild @AndyGerlicher

@KevinRansom
Copy link
Member

KevinRansom commented May 25, 2017

@enricosada

We can override : https://github.com/dotnet/sdk/blob/8204b6b1f3ff2f9717c5d66ab903795271de2e9c/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.GenerateAssemblyInfo.targets#L51

in our targets file and sdk apps will work fine.

But we should also send a PR to the dotnet sdk refactoring the current implementation a bit.
@nguerrera said he would welcome a PR that improved this :-)

The bit where the attributes are generated should be moved to a new target: GetAssemblyAttributes or some such name.

And then : CoreGenerateAssemblyInfo just handles the write.

We can override CoreGenerateAssemblyInfo to write the attributes with a build task added to the Microsoft.FSharp.Build library ... or something.

Does that make sense?

Enrico,
thanks for pushing on this, it's really great that you take the time to dive into all of the stuff.

Kevin

@dasMulli
Copy link
Contributor

But we should also send a PR to the dotnet sdk refactoring the current implementation a bit.

There's already dotnet/sdk#1007 which splits the target into _CalculateAssemblyAttributes and CoreGenerateAssemblyInfo but it probably won't land in its current form (see PR discussion. I'll be sending out a PR today for an alternative implementation)

@enricosada
Copy link
Author

Awesome @dasMulli , can you please add me and @KevinRansom and reference the f# issue dotnet/fsharp#3113 in that PR, so we'll update.

@@ -641,6 +641,32 @@ public void OneAttributePositionalAndNamedParamsVisualBasic()
File.Delete(task.OutputFile.ItemSpec);
}

/// <summary>
/// Test with the VB language
Copy link
Contributor

Choose a reason for hiding this comment

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

F#, not VB

string content = File.ReadAllText(task.OutputFile.ItemSpec);
Console.WriteLine(content);

CheckContentFSharp(content, "[<assembly: System.AssemblyTrademarkAttribute()>]");
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe test with multiple attributes and attributes with parameters?

@@ -152,6 +152,12 @@ public override bool Execute()
[SuppressMessage("Microsoft.Globalization", "CA1305:SpecifyIFormatProvider", MessageId = "System.IO.StringWriter.#ctor(System.Text.StringBuilder)", Justification = "Reads fine to me")]
private string GenerateCode(out string extension)
{
if (Language.ToLowerInvariant() == "f#")
{
//no codedoom for F#, fallback to coreclr version
Copy link
Contributor

Choose a reason for hiding this comment

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

"Code DOM" not "codedoom"

@enricosada
Copy link
Author

Thx for review @saul but this is going to Ben replaced with another, without writecodegragment

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.

6 participants