-
Notifications
You must be signed in to change notification settings - Fork 325
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
Auto-generate F# program file #1664
Changes from 2 commits
72cdfdc
4e68110
13f4d46
ba470a5
6e1aa3c
c888e5b
c33be0e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,7 +56,7 @@ | |
Condition="'$(GenerateProgramFile)' == 'true'" /> | ||
|
||
<Target Name="CoreGenerateProgramFile" | ||
Condition="'$(Language)'=='VB' or '$(Language)'=='C#'" | ||
Condition="'$(Language)'=='VB' or '$(Language)'=='C#' or '$(Language)'=='F#'" | ||
Inputs="$(MSBuildAllProjects)" | ||
Outputs="$(GeneratedProgramFile)"> | ||
|
||
|
@@ -76,15 +76,26 @@ | |
<Line Include="End Sub"/> | ||
<Line Include="End Module"/> | ||
</ItemGroup> | ||
|
||
<ItemGroup Condition="'$(Language)'=='F#'"> | ||
<Line Include="module Program"/> | ||
<Line Include="[<EntryPoint>]"/> | ||
<Line Include="let main _ = 0"/> | ||
</ItemGroup> | ||
|
||
<WriteLinesToFile | ||
File="$(GeneratedProgramFile)" Lines="@(Line)" Overwrite="true" Encoding="Unicode"> | ||
</WriteLinesToFile> | ||
|
||
<!-- | ||
Compile Include the generated Program File | ||
--> | ||
<ItemGroup> | ||
<ItemGroup Condition="'$(Language)'!='F#'"> | ||
<Compile Include="$(GeneratedProgramFile)"/> | ||
</ItemGroup> | ||
|
||
<ItemGroup Condition="'$(Language)'=='F#'"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure @saul did you test simple unit test project of F# with your changes? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I understood what is CompileAfter. Now it makes sense after reading issue one more time. I have checked out your branch and verified E2E scenario. Below are the issue we need to address.
PS C:\Users\samadala\tmp\fs-test-project> dotnet test
Build started, please wait...
C:\Users\samadala\tmp\fs-test-project\Program.fs(1,1): error FS0222: Files in libraries or multiple-file applications must begin with a namespace or module declaration. When using a module declaration at the start of a file the '=' sign is not allowed. If this is a top-level module, consider removing the = to resolve this error. [C:\Users\samadala\tmp\fs-test-project\fs-test-project.fsproj] This can be fixed by removing
This can be fixed by adding check here that don't include @saul Can you please fix the seconds issue in this PR? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @smadala - I've fixed the second problem. I've added a warning: This lets the user either remove their Program.fs, or disables There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @saul Adding warning is very good idea. |
||
<CompileAfter Include="$(GeneratedProgramFile)"/> | ||
</ItemGroup> | ||
</Target> | ||
</Project> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will fail if another module is named
Program
. It would probably be better to do something likemodule ``VSTest-AutoGenerated-Program``
It can still have collisions, but way less likely. Also, both the C# and the VB version is decorated with
TestSDKAutoGeneratedCodeAttribute
which is probably a good idea.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch - I'll fix that.