Skip to content
This repository was archived by the owner on Dec 18, 2017. It is now read-only.

Commit

Permalink
Remove name from project.json
Browse files Browse the repository at this point in the history
- It's always inferred from the folder name.
#198
  • Loading branch information
davidfowl committed Jun 18, 2014
1 parent ff83c31 commit 153beba
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 21 deletions.
13 changes: 4 additions & 9 deletions src/Microsoft.Framework.Runtime/Project.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,14 @@ public static bool TryGetProject(string path, out Project project)
var json = File.ReadAllText(projectPath);

// Assume the directory name is the project name if none was specified
var fallbackProjectName = GetDirectoryName(path);
var projectName = GetDirectoryName(path);

project = GetProject(json, fallbackProjectName, projectPath);
project = GetProject(json, projectName, projectPath);

return true;
}

public static Project GetProject(string json, string fallbackProjectName, string projectPath)
public static Project GetProject(string json, string projectName, string projectPath)
{
var project = new Project();

Expand All @@ -174,13 +174,8 @@ public static Project GetProject(string json, string fallbackProjectName, string
// Metadata properties
var version = rawProject["version"];
var authors = rawProject["authors"];
project.Name = GetValue<string>(rawProject, "name");

if (string.IsNullOrEmpty(project.Name))
{
project.Name = fallbackProjectName;
}

project.Name = projectName;
project.Version = version == null ? new SemanticVersion("1.0.0") : new SemanticVersion(version.Value<string>());
project.Description = GetValue<string>(rawProject, "description");
project.Authors = authors == null ? new string[] { } : authors.ToObject<string[]>();
Expand Down
14 changes: 2 additions & 12 deletions test/Microsoft.Framework.Runtime.Tests/ProjectFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,13 @@ namespace Microsoft.Framework.Runtime.Tests
public class ProjectFacts
{
[Fact]
public void FallbackProjectNameIsUsedIfNoneSpecified()
{
// Arrange & Act
var project = Project.GetProject(@"{}", @"foo", @"c:\foo\project.json");

// Act
Assert.Equal("foo", project.Name);
}

[Fact]
public void NameOverridesFallbackName()
public void NameIsIgnoredIsSpecified()
{
// Arrange & Act
var project = Project.GetProject(@"{ ""name"": ""hello"" }", @"foo", @"c:\foo\project.json");

// Assert
Assert.Equal("hello", project.Name);
Assert.Equal("foo", project.Name);
}

[Fact]
Expand Down

0 comments on commit 153beba

Please sign in to comment.