This project is read-only.

F# Support

May 12, 2011 at 12:59 AM
Edited May 12, 2011 at 1:03 AM

I was able to add F# support by simply adding the following to ReplaceVersionInFile.cs:InsertAssemblyVersion

 

        private static string InsertAssemblyVersion(string fileExtension, string versionTitle, string fileData, string version)
        {
            var fileDataOut = new StringBuilder(fileData);
            var versionShell = "[assembly: {0}(\"{1}\")]";
            var normalizedFileExt = fileExtension.ToLower();

            if (normalizedFileExt == ".fs")
            {
                fileDataOut.Replace("do ()", "");
                fileDataOut.Replace("do()", "");
            }

            // default is C#, change if different
            switch (normalizedFileExt)
            {
                case ".cpp":
                    versionShell = "[assembly:{0}Attribute(\"{1}\")]";
                    break;
                case ".vb":
                    versionShell = "<Assembly: {0}(\"{1}\")>";
                    break;
                case ".fs":
                    versionShell = "[<assembly: {0}(\"{1}\")>]";
                    break;
            }
            var versionLine = string.Format(versionShell, versionTitle, version);

            fileDataOut.Append("\r\n");
            fileDataOut.Append(versionLine);
            fileDataOut.Append("\r\n");

            if (normalizedFileExt == ".fs")
            {
                fileDataOut.Append("do ()");
                fileDataOut.Append("\r\n");
            }

            return fileDataOut.ToString();
        }

 

 

Here's a test WrapperTestAssemblyInfo.fs

 

 

open System.Reflection
open System.Runtime.CompilerServices
open System.Runtime.InteropServices

// General Information about an assembly is controlled through the following 
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[<assembly: AssemblyTitle("ClassLibrary2")>]
[<assembly: AssemblyDescription("")>]
[<assembly: AssemblyConfiguration("")>]
[<assembly: AssemblyCompany("Microsoft")>]
[<assembly: AssemblyProduct("ClassLibrary2")>]
[<assembly: AssemblyCopyright("Copyright � Microsoft 2009")>]
[<assembly: AssemblyTrademark("")>]
[<assembly: AssemblyCulture("")>]

// Setting ComVisible to false makes the types in this assembly not visible 
// to COM components.  If you need to access a type in this assembly from 
// COM, set the ComVisible attribute to true on that type.
[<assembly: ComVisible(false)>]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[<assembly: Guid("2bdfbb3a-f046-40b2-a950-3e1cda8b786d")>]

// Version information for an assembly consists of the following foyTitle("ClassLibrary2")>]
[<assembly: AssemblyDescription("")>]
[<assembly: Assembly3E
//      Build Number 
//      Revision
//
// You can specify all the values or you can default the Build and Revision Numbers 
// by using the '*' as shown below:

[<assembly: AssemblyVersion("1.0.3.0")>]

[<assembly: AssemblyFileVersion("1.0.11082.1")>]
do ()

 

and a test ReplaceTestAssemblyInfo.fs

 

 

open System.Reflection
open System.Runtime.CompilerServices
open System.Runtime.InteropServices

[<assembly: AssemblyTitle("ClassLibrary2")>]
[<assembly: AssemblyDescription("")>]
[<assembly: AssemblyConfiguration("")>]
[<assembly: AssemblyCompany("Microsoft")>]
[<assembly: AssemblyProduct("ClassLibrary2")>]
[<assembly: AssemblyCopyright("Copyright � Microsoft 2009")>]
[<assembly: AssemblyTrademark("")>]
[<assembly: AssemblyCulture("")>]
[<assembly: ComVisible(false)>]
[<assembly: Guid("2bdfbb3a-f046-40b2-a950-3e1cda8b786d")>]
do ()
Coordinator
May 12, 2011 at 9:05 PM

Thanks Rickasaurus!

I hadn't even looked at F# - my bad.  I am going to add your changes and test and then see about reposting.

Thanks for passing that on.

Regards,

Mark

Coordinator
May 12, 2011 at 9:07 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
May 13, 2011 at 12:23 AM

Thanks for the fast response! Looking forward to seeing F# support.

Now, if only there was a way to make components that didn't require so much work to integrate into an existing workflow!

Coordinator
May 14, 2011 at 9:53 PM

Version 1.3.1.0 has been updated to support F# assembly versioning.

I used your code as a base to start from but added RegEx to handle the "do ()" replacement because of RegEx's ability to handle all the different possibilities of whitespace.  However, the spirit of your additions remain. 

Also added tests to verify the new feature code.

Thanks for passing on your suggestion and let me know how this works out for you.

Regards,  Mark