Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
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
3 changes: 2 additions & 1 deletion src/NuGet.Core/NuGet.ProjectModel/DependencyGraphSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using System.IO;
using System.Linq;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NuGet.Common;
using NuGet.Packaging;

Expand Down Expand Up @@ -253,7 +252,9 @@ public static DependencyGraphSpec Load(string path)
case "projects":
jsonReader.ReadObject(projectsPropertyName =>
{
#pragma warning disable CS0612 // Type or member is obsolete
PackageSpec packageSpec = JsonPackageSpecReader.GetPackageSpec(jsonReader, path);
#pragma warning restore CS0612 // Type or member is obsolete

dgspec._projects.Add(projectsPropertyName, packageSpec);
});
Expand Down
52 changes: 28 additions & 24 deletions src/NuGet.Core/NuGet.ProjectModel/FileFormatException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,18 @@ internal static FileFormatException Create(Exception exception, int line, int co
return ex.WithFilePath(path).WithLineInfo(line, column);
}

internal static FileFormatException Create(Exception exception, string path)
{
var message = string.Format(CultureInfo.CurrentCulture,
Strings.Log_ErrorReadingProjectJson,
path,
exception.Message);

var ex = new FileFormatException(message, exception);

return ex.WithFilePath(path);
}

public static FileFormatException Create(string message, JToken value, string path)
{
var lineInfo = (IJsonLineInfo)value;
Expand All @@ -101,32 +113,24 @@ internal static FileFormatException Create(string message, int line, int column,
return ex.WithFilePath(path).WithLineInfo(line, column);
}

internal static FileFormatException Create(Exception exception, string path)
internal static FileFormatException Create(JsonReaderException exception, string path)
{
var jex = exception as JsonReaderException;

string message;
if (jex == null)
{
message = string.Format(CultureInfo.CurrentCulture,
Strings.Log_ErrorReadingProjectJson,
path,
exception.Message);

return new FileFormatException(message, exception).WithFilePath(path);
}
else
{
message = string.Format(CultureInfo.CurrentCulture,
Strings.Log_ErrorReadingProjectJsonWithLocation,
path, jex.LineNumber,
jex.LinePosition,
exception.Message);

return new FileFormatException(message, exception)
.WithFilePath(path)
.WithLineInfo(jex);
}
message = string.Format(CultureInfo.CurrentCulture,
Strings.Log_ErrorReadingProjectJsonWithLocation,
path, exception.LineNumber,
exception.LinePosition,
exception.Message);

return new FileFormatException(message, exception)
.WithFilePath(path)
.WithLineInfo(exception);
}

internal static FileFormatException Create(string message, string path)
{
return new FileFormatException(message)
.WithFilePath(path);
}
}
}
Loading