phmonte / Buildalyzer

A utility to perform design-time builds of .NET projects without having to think too hard about it.
MIT License
593 stars 94 forks source link

Some thoughts about F# #145

Closed dukedagmor closed 3 years ago

dukedagmor commented 3 years ago

I am currently researching the possibility for https://github.com/stryker-mutator/stryker-net to get F# support. Since Stryker.NET uses Buildalyzer I've looked into the possibility for Buildalyzer to use F# since it would make the expansion for Stryker easier to make. my quest: get Buildalyzer to set the sourcefiles and references of a given F# sollution. (corecompile output)

so far I've got this:

BuildalyzerLogger
        private void MessageRaised(object sender, BuildMessageEventArgs e)
        {
            // Only send if in the the Csc & FSc task
            if ((e is TaskCommandLineEventArgs cmd
                && string.Equals(cmd.TaskName, "Csc", StringComparison.OrdinalIgnoreCase)) || string.Equals(e.SenderName, "Fsc", StringComparison.OrdinalIgnoreCase))
            {
                Pipe.Write(e);
            }
        }

Add to EventProcessor eventSource.AnyEventRaised += AnyEventRaised; eventSource.AnyEventRaised -= AnyEventRaised;

        private void AnyEventRaised(object sender, BuildEventArgs e)
        {
            if (e.SenderName.Equals("Fsc", StringComparison.OrdinalIgnoreCase) || e.SenderName.Equals("Csc", StringComparison.OrdinalIgnoreCase))
            {
                Console.WriteLine(e);
                Console.WriteLine(e.Message);
                Console.WriteLine(e.BuildEventContext);
            }
        }

My findings: the first time it gets to the print statements it prints the output of corecompile

corecompile does NOT trigger an TaskCommandLineEventArgs event if an F# project was given

I'll continue to post updates as I make progress I've opened an issue on the fsharp github to try and get more answers on why no TaskCommandLineEventArgs is used It seems to me that it is more common to set a custom target and to get the data from there instead of logging

dukedagmor commented 3 years ago

image It's possible 🎉