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

Add F# support #1670

Merged
merged 19 commits into from
Mar 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
6c2e4c7
Add projects for F#
srivatsn Feb 24, 2017
9327143
Create a F# project system package and add rules and design time targ…
srivatsn Feb 24, 2017
3281ee9
Add an image provider for F# project root node.
srivatsn Feb 24, 2017
d71cd09
Hack around CreateProjectContext needing a different overload for F#
srivatsn Feb 28, 2017
dcdaec6
Add a F# commandline parser stub.
srivatsn Feb 28, 2017
6bf4280
Add F# test projects.
srivatsn Mar 2, 2017
b0746c6
Merging with upstream/master
srivatsn Mar 24, 2017
e9ca79b
Mark all components as supporting the FSharp capability and remove th…
srivatsn Mar 25, 2017
c6a274f
Adding a guid provider and adding tests.
srivatsn Mar 25, 2017
1ad8207
Add a F# property page provider with all the guids pages. The pages t…
srivatsn Mar 25, 2017
d29be9b
Add setupauthoring for the targets and xaml files. Localization still…
srivatsn Mar 25, 2017
1b9f303
Fix typo Csc->Fsc
srivatsn Mar 28, 2017
c93fa03
Merge remote-tracking branch 'upstream/master' into fsharp
srivatsn Mar 28, 2017
94459bb
Bring back ProjectCapabilities.CSharpOrVisualBasic because the newly …
srivatsn Mar 28, 2017
018b486
Add FSharp as a default capability and disable async project tree load.
srivatsn Mar 29, 2017
72e11e7
Remove registration of the Debug prop page since that'll be registere…
srivatsn Mar 29, 2017
87cc359
Use the Managed capability instead of CSharpOrVisualBasicOrFsharp
srivatsn Mar 29, 2017
4a9bdd8
Remove the registration of SingleFileGenerators since the old F# PS d…
srivatsn Mar 29, 2017
91e5b1c
Merge remote-tracking branch 'upstream/master' into fsharp
srivatsn Mar 29, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/DeployTestDependencies/DeployTestDependencies.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
<ProjectReference Include="..\Microsoft.VisualStudio.Editors\Microsoft.VisualStudio.Editors.vbproj" />
<ProjectReference Include="..\Microsoft.VisualStudio.ProjectSystem.CSharp.VS\Microsoft.VisualStudio.ProjectSystem.CSharp.VS.csproj" />
<ProjectReference Include="..\Microsoft.VisualStudio.ProjectSystem.CSharp\Microsoft.VisualStudio.ProjectSystem.CSharp.csproj" />
<ProjectReference Include="..\Microsoft.VisualStudio.ProjectSystem.FSharp.VS\Microsoft.VisualStudio.ProjectSystem.FSharp.VS.csproj" />
<ProjectReference Include="..\Microsoft.VisualStudio.ProjectSystem.FSharp\Microsoft.VisualStudio.ProjectSystem.FSharp.csproj" />
<ProjectReference Include="..\Microsoft.VisualStudio.ProjectSystem.Managed.TestServices\Microsoft.VisualStudio.ProjectSystem.Managed.TestServices.csproj" />
<ProjectReference Include="..\Microsoft.VisualStudio.ProjectSystem.Managed.VS\Microsoft.VisualStudio.ProjectSystem.Managed.VS.csproj" />
<ProjectReference Include="..\Microsoft.VisualStudio.ProjectSystem.Managed\Microsoft.VisualStudio.ProjectSystem.Managed.csproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!-- Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -->
<Project>
<Import Project="..\..\build\Targets\VSL.Settings.targets" />
<PropertyGroup>
<RootNamespace>Microsoft.VisualStudio</RootNamespace>
<TargetFramework>net46</TargetFramework>
<SignAssembly>true</SignAssembly>
<Nonshipping>true</Nonshipping>
<UseCommonOutputDirectory>true</UseCommonOutputDirectory>
<OutDir>$(OutDir)Tests\</OutDir>
<ProjectSystemLayer>HostAgnostic</ProjectSystemLayer>
<ProjectSystemProjectType>Test</ProjectSystemProjectType>
</PropertyGroup>
<ItemGroup>
<InternalsVisibleToTest Include="Microsoft.VisualStudio.ProjectSystem.FSharp.VS.UnitTests" />
<InternalsVisibleToMoq Include="DynamicProxyGenAssembly2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DeployTestDependencies\DeployTestDependencies.csproj">
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\Microsoft.VisualStudio.ProjectSystem.FSharp\Microsoft.VisualStudio.ProjectSystem.FSharp.csproj" />
<ProjectReference Include="..\Microsoft.VisualStudio.ProjectSystem.Managed.TestServices\Microsoft.VisualStudio.ProjectSystem.Managed.TestServices.csproj" />
<ProjectReference Include="..\Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests\Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests.csproj" />
<ProjectReference Include="..\Microsoft.VisualStudio.ProjectSystem.Managed\Microsoft.VisualStudio.ProjectSystem.Managed.csproj" />
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests\Properties\AssemblyAttributes.cs">
<Link>Properties\AssemblyAttributes.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="..\Common\Test\App.config">
<Link>App.config</Link>
</None>
</ItemGroup>
<Import Project="..\..\build\Targets\VSL.Imports.targets" />
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<!-- Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -->
<Project>
<Import Project="..\..\build\Targets\VSL.Settings.targets" />
<PropertyGroup>
<RootNamespace>Microsoft.VisualStudio</RootNamespace>
<TargetFramework>net46</TargetFramework>
<SignAssembly>true</SignAssembly>
<Nonshipping>true</Nonshipping>
<UseCommonOutputDirectory>true</UseCommonOutputDirectory>
<OutDir>$(OutDir)Tests\</OutDir>
<ProjectSystemLayer>VisualStudio</ProjectSystemLayer>
<ProjectSystemProjectType>Test</ProjectSystemProjectType>
</PropertyGroup>
<ItemGroup>
<InternalsVisibleToMoq Include="DynamicProxyGenAssembly2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DeployTestDependencies\DeployTestDependencies.csproj">
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\Microsoft.VisualStudio.ProjectSystem.FSharp.VS\Microsoft.VisualStudio.ProjectSystem.FSharp.VS.csproj" />
<ProjectReference Include="..\Microsoft.VisualStudio.ProjectSystem.FSharp\Microsoft.VisualStudio.ProjectSystem.FSharp.csproj" />
<ProjectReference Include="..\Microsoft.VisualStudio.ProjectSystem.Managed.TestServices\Microsoft.VisualStudio.ProjectSystem.Managed.TestServices.csproj" />
<ProjectReference Include="..\Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests\Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests.csproj" />
<ProjectReference Include="..\Microsoft.VisualStudio.ProjectSystem.Managed.VS.UnitTests\Microsoft.VisualStudio.ProjectSystem.Managed.VS.UnitTests.csproj" />
<ProjectReference Include="..\Microsoft.VisualStudio.ProjectSystem.Managed.VS\Microsoft.VisualStudio.ProjectSystem.Managed.VS.csproj" />
<ProjectReference Include="..\Microsoft.VisualStudio.ProjectSystem.Managed\Microsoft.VisualStudio.ProjectSystem.Managed.csproj" />
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests\Properties\AssemblyAttributes.cs">
<Link>Properties\AssemblyAttributes.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="..\Common\Test\App.config">
<Link>App.config</Link>
</None>
</ItemGroup>
<Import Project="..\..\build\Targets\VSL.Imports.targets" />
<Import Project="..\..\build\Targets\Roslyn.Toolsets.Xunit.targets" />
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using Xunit;

namespace Microsoft.VisualStudio.Packaging
{
[ProjectSystemTrait]
public class FSharpProjectSystemPackageTests
{
[Fact]
public void Constructor_DoesNotThrow()
{
new FSharpProjectSystemPackage();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using Microsoft.VisualStudio.ProjectSystem.Imaging;
using Xunit;

namespace Microsoft.VisualStudio.ProjectSystem.VS.Imaging
{
[ProjectSystemTrait]
public class FSharpProjectImageProviderTests
{
[Fact]
public void Constructor_DoesNotThrow()
{
new FSharpProjectImageProvider();
}

[Fact]
public void GetProjectImage_NullAsKey_ThrowsArgumentNull()
{
var provider = CreateInstance();

Assert.Throws<ArgumentNullException>("key", () => {

provider.GetProjectImage((string)null);
});
}


[Fact]
public void GetProjectImage_EmptyAsKey_ThrowsArgument()
{
var provider = CreateInstance();

Assert.Throws<ArgumentException>("key", () => {

provider.GetProjectImage(string.Empty);
});
}

[Fact]
public void GetProjectImage_UnrecognizedKeyAsKey_ReturnsNull()
{
var provider = CreateInstance();

var result = provider.GetProjectImage("Unrecognized");

Assert.Null(result);
}

[Theory]
[InlineData(ProjectImageKey.ProjectRoot)]
[InlineData(ProjectImageKey.AppDesignerFolder)]
public void GetProjectImage_RecognizedKeyAsKey_ReturnsNonNull(string key)
{
var provider = CreateInstance();

var result = provider.GetProjectImage(key);

Assert.NotNull(result);
}

private static FSharpProjectImageProvider CreateInstance()
{
return new FSharpProjectImageProvider();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Linq;
using System.Threading.Tasks;
using Xunit;

namespace Microsoft.VisualStudio.ProjectSystem.VS.Properties
{
[ProjectSystemTrait]
public class FSharpProjectDesignerPageProviderTests
{
[Fact]
public void Constructor_DoesNotThrow()
{
CreateInstance();
}

[Fact]
public async Task GetPagesAsync_ReturnsPagesInOrder()
{
var provider = CreateInstance();
var pages = await provider.GetPagesAsync();

Assert.Equal(pages.Count(), 5);
Assert.Same(pages.ElementAt(0), FSharpProjectDesignerPage.Application);
Assert.Same(pages.ElementAt(1), FSharpProjectDesignerPage.Build);
Assert.Same(pages.ElementAt(2), FSharpProjectDesignerPage.BuildEvents);
Assert.Same(pages.ElementAt(3), FSharpProjectDesignerPage.Debug);
Assert.Same(pages.ElementAt(4), FSharpProjectDesignerPage.ReferencePaths);
}

[Fact]
public async Task GetPagesAsync_WithPackCapability()
{
var provider = CreateInstance(ProjectCapability.Pack);
var pages = await provider.GetPagesAsync();

Assert.Equal(pages.Count(), 6);
Assert.Same(pages.ElementAt(0), FSharpProjectDesignerPage.Application);
Assert.Same(pages.ElementAt(1), FSharpProjectDesignerPage.Build);
Assert.Same(pages.ElementAt(2), FSharpProjectDesignerPage.BuildEvents);
Assert.Same(pages.ElementAt(3), FSharpProjectDesignerPage.Debug);
Assert.Same(pages.ElementAt(4), FSharpProjectDesignerPage.Package);
Assert.Same(pages.ElementAt(5), FSharpProjectDesignerPage.ReferencePaths);
}

private static FSharpProjectDesignerPageProvider CreateInstance(params string[] capabilities)
{
Func<string, bool> containsCapability = c => capabilities.Contains(c);
var capabilitiesService = IProjectCapabilitiesServiceFactory.ImplementsContains(containsCapability);
return new FSharpProjectDesignerPageProvider(capabilitiesService);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc.

// workaround for https://github.com/dotnet/roslyn-analyzers/issues/955
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage(
"Reliability",
"RS0006:Do not mix attributes from different versions of MEF",
Justification = "<Pending>")]
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!-- Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -->
<Project>
<Import Project="..\..\build\Targets\VSL.Settings.targets" />
<PropertyGroup>
<RootNamespace>Microsoft.VisualStudio</RootNamespace>
<TargetFramework>net46</TargetFramework>
<GeneratePkgDefFile>true</GeneratePkgDefFile>
<ImportVSSDKTargets>true</ImportVSSDKTargets>
<CreateVsixContainer>false</CreateVsixContainer>
<DeployExtension>false</DeployExtension>
<UseCodebase>true</UseCodebase>
<SignAssembly>true</SignAssembly>
<UseCommonOutputDirectory>true</UseCommonOutputDirectory>
<ProjectSystemLayer>VisualStudio</ProjectSystemLayer>
</PropertyGroup>
<ItemGroup>
<InternalsVisibleToTest Include="Microsoft.VisualStudio.ProjectSystem.FSharp.VS.UnitTests" />
<InternalsVisibleToMoq Include="DynamicProxyGenAssembly2" />
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Microsoft.VisualStudio.ProjectSystem.FSharp\Microsoft.VisualStudio.ProjectSystem.FSharp.csproj" />
<ProjectReference Include="..\Microsoft.VisualStudio.ProjectSystem.Managed.VS\Microsoft.VisualStudio.ProjectSystem.Managed.VS.csproj" />
<ProjectReference Include="..\Microsoft.VisualStudio.ProjectSystem.Managed\Microsoft.VisualStudio.ProjectSystem.Managed.csproj" />
</ItemGroup>
<Import Project="..\..\build\Targets\VSL.Imports.targets" />
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Runtime.InteropServices;
using Microsoft.VisualStudio.Packaging;
using Microsoft.VisualStudio.ProjectSystem.VS;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.ProjectSystem;

// We register ourselves as a new CPS "project type"
[assembly: ProjectTypeRegistration(projectTypeGuid: FSharpProjectSystemPackage.ProjectTypeGuid, displayName: "#1", displayProjectFileExtensions: "#2", defaultProjectExtension: "fsproj", language: "FSharp", resourcePackageGuid: FSharpProjectSystemPackage.PackageGuid, Capabilities = ManagedProjectSystemPackage.DefaultCapabilities + "; " + ProjectCapability.FSharp, DisableAsynchronousProjectTreeLoad = true)]

namespace Microsoft.VisualStudio.Packaging
{
[Guid(PackageGuid)]
[PackageRegistration(AllowsBackgroundLoading = true, RegisterUsing = RegistrationMethod.CodeBase, UseManagedResourcesOnly = true)]
[DplOptOutRegistration(ProjectTypeGuid, true)]
internal class FSharpProjectSystemPackage : AsyncPackage
{
public const string ProjectTypeGuid = "6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705";
public const string LegacyProjectTypeGuid = "F2A71F9B-5D33-465A-A702-920D77279786";
public const string PackageGuid = "a724c878-e8fd-4feb-b537-60baba7eda83";
private const string ProjectTypeGuidFormatted = "{" + ProjectTypeGuid + "}";

public FSharpProjectSystemPackage()
{
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.ComponentModel.Composition;
using Microsoft.VisualStudio.Packaging;

namespace Microsoft.VisualStudio.ProjectSystem.VS
{
/// <summary>
/// Provides the Visual Basic implementation of <see cref="IItemTypeGuidProvider"/>.
Copy link
Contributor

Choose a reason for hiding this comment

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

Visual Basic -> FSharp

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess there are lot of places where Visual Basic or C# will be present instead of F#. As we implement the component we should update these files.

/// </summary>
[Export(typeof(IItemTypeGuidProvider))]
[AppliesTo(ProjectCapability.FSharp)]
internal class FSharpProjectGuidProvider : IItemTypeGuidProvider
{
private static readonly Guid s_fsharpProjectType = new Guid(FSharpProjectSystemPackage.LegacyProjectTypeGuid);

[ImportingConstructor]
public FSharpProjectGuidProvider(UnconfiguredProject unconfiguredProject)
{
Requires.NotNull(unconfiguredProject, nameof(unconfiguredProject));
}

public Guid ProjectTypeGuid
{
get { return s_fsharpProjectType; }
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.ComponentModel.Composition;
using Microsoft.VisualStudio.Imaging;
using Microsoft.VisualStudio.ProjectSystem.Imaging;

namespace Microsoft.VisualStudio.ProjectSystem.VS.Imaging
{
/// <summary>
/// Provides C# project images.
/// </summary>
[Export(typeof(IProjectImageProvider))]
[AppliesTo(ProjectCapability.FSharp)]
[Order(2)]
internal class FSharpProjectImageProvider : IProjectImageProvider
{
[ImportingConstructor]
public FSharpProjectImageProvider()
{
}

public ProjectImageMoniker GetProjectImage(string key)
{
Requires.NotNullOrEmpty(key, nameof(key));

switch (key)
{
case ProjectImageKey.ProjectRoot:
return KnownMonikers.FSProjectNode.ToProjectSystemType();

case ProjectImageKey.AppDesignerFolder:
return KnownMonikers.Property.ToProjectSystemType();

default:
return null;
}
}
}
}
Loading