Skip to content

Commit

Permalink
Add back support for project.json #1254 (#1541)
Browse files Browse the repository at this point in the history
  • Loading branch information
vicancy committed Apr 12, 2017
1 parent 42d8138 commit d1f5ad3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion RELEASENOTE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ v2.15
1. Bug fixes:
1. Auto dedent the included code snippet, both when including the whole file and file sections.
2. [Breaking Change]For inline inclusion, trim ending white spaces, considering ending white spaces in inline inclusion in most cases are typos.
2. [Breaking Change] Support NetCore projects, the legacy `project.json` is no longer supported
2. Support the latest csproj format `<Project Sdk="Microsoft.NET.Sdk">`
3. Following GitHub markdown behavior changes.

v2.14
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace Microsoft.DocAsCode.Metadata.ManagedReference

using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.MSBuild;
using Microsoft.DotNet.ProjectModel.Workspaces;

using Microsoft.DocAsCode.Common;
using Microsoft.DocAsCode.DataContracts.Common;
Expand All @@ -27,6 +28,7 @@ public sealed class ExtractMetadataWorker : IDisposable
{ "Configuration", "Release" }
}));
private static readonly string[] SupportedSolutionExtensions = { ".sln" };
private static readonly string[] SupportedProjectName = { "project.json" };
private static readonly string[] SupportedProjectExtensions = { ".csproj", ".vbproj" };
private static readonly string[] SupportedSourceFileExtensions = { ".cs", ".vb" };
private static readonly string[] SupportedVBSourceFileExtensions = { ".vb" };
Expand Down Expand Up @@ -169,7 +171,7 @@ from m in GetExtensionMethodPerNamespace(n)
#region Check Supportability
private static bool IsSupported(string filePath)
{
return IsSupported(filePath, SupportedExtensions);
return IsSupported(filePath, SupportedExtensions, SupportedProjectName);
}

private static bool IsSupportedSolution(string filePath)
Expand All @@ -179,7 +181,7 @@ private static bool IsSupportedSolution(string filePath)

private static bool IsSupportedProject(string filePath)
{
return IsSupported(filePath, SupportedProjectExtensions);
return IsSupported(filePath, SupportedProjectExtensions, SupportedProjectName);
}

private static bool IsSupportedSourceFile(string filePath)
Expand Down Expand Up @@ -924,6 +926,12 @@ private async Task<Project> GetProjectAsync(string path)
{
string name = Path.GetFileName(path);

if (name.Equals("project.json", StringComparison.OrdinalIgnoreCase))
{
var workspace = new ProjectJsonWorkspace(path);
return workspace.CurrentSolution.Projects.FirstOrDefault(p => p.FilePath == Path.GetFullPath(path));
}

return await _workspace.Value.OpenProjectAsync(path);
}
catch (Exception e)
Expand Down

0 comments on commit d1f5ad3

Please sign in to comment.