Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
c870c41
Initial commit,...
jgonz120 Nov 3, 2023
9083583
Finshed up moving all the objects to use STJ
jgonz120 Nov 6, 2023
49541e0
Added a really long unit test but then just validated using other uni…
jgonz120 Nov 8, 2023
4d1fe5b
Went through the lock file converters, using Utf8JsonReaderExtensions
jgonz120 Nov 8, 2023
a1af274
Seperated the STJ logic from the JsonPackageSpec reader
jgonz120 Nov 9, 2023
39fffa5
Small optimizations
jgonz120 Nov 10, 2023
da7d17c
Split the JsonPackageReader, added obsolete and surpressed in tests
jgonz120 Nov 10, 2023
9f9738f
Changes to get unit tests working for exceptions
jgonz120 Nov 13, 2023
d3d9f32
merge
jgonz120 Nov 13, 2023
0e02fe1
Updated Package reader with new field
jgonz120 Nov 13, 2023
8422e96
Updated exception unit test
jgonz120 Nov 14, 2023
a5fdf9a
Fix unit tests wrt to exceptions
jgonz120 Nov 14, 2023
57813dd
Implemented deserialization with memory stream
jgonz120 Nov 16, 2023
1cb4fd3
Updated tests to work with new streaming logic
jgonz120 Nov 16, 2023
08b36d1
Update tests to use double quotes instead of single quotes for json
jgonz120 Nov 20, 2023
6e3a887
Additonal single quote removals
jgonz120 Nov 20, 2023
1dc7682
Fix another test that uses single quotes
jgonz120 Nov 21, 2023
e62dcfe
Added unit tests and renamed some functions
jgonz120 Nov 21, 2023
5cd4486
Arrange files
jgonz120 Nov 21, 2023
e1d989d
Rename StreamingUtf8JsonReader to Utf8JsonStreamReader
jgonz120 Nov 21, 2023
68c2021
change classes to no longer implement converter
jgonz120 Nov 22, 2023
3ab5dd4
Added environment variable check
jgonz120 Nov 22, 2023
d0fa9ca
updated comments
jgonz120 Nov 22, 2023
20658a6
merge with dev
jgonz120 Dec 4, 2023
9df9654
Remove the floating package version
jgonz120 Dec 4, 2023
3895c46
removed unused references
jgonz120 Dec 4, 2023
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
56 changes: 42 additions & 14 deletions src/NuGet.Core/NuGet.ProjectModel/FileFormatException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ namespace NuGet.ProjectModel
{
public class FileFormatException : Exception
{
static internal string SurfaceMessage = "SurfaceMessage";

public FileFormatException(string message)
: base(message)
{
Expand Down Expand Up @@ -47,6 +49,14 @@ private FileFormatException WithLineInfo(int line, int column)
return this;
}

private FileFormatException WithLineInfo(long? line, long? column)
{
Line = unchecked((int)line.Value);
Column = unchecked((int)column);

return this;
}

private FileFormatException WithLineInfo(IJsonLineInfo lineInfo)
{
Line = lineInfo.LineNumber;
Expand Down Expand Up @@ -101,32 +111,50 @@ 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;
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(System.Text.Json.JsonException exception, string path)
{
string message;
if (jex == null)
if (exception.Data.Contains(SurfaceMessage))
{
message = exception.Message;
}
else if (exception.BytePositionInLine is not null && exception.LineNumber is not null)
{
message = string.Format(CultureInfo.CurrentCulture,
Strings.Log_ErrorReadingProjectJson,
path,
Strings.Log_ErrorReadingProjectJsonWithLocation,
path, exception.LineNumber,
exception.BytePositionInLine,
exception.Message);

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

return new FileFormatException(message, exception)
.WithFilePath(path)
.WithLineInfo(jex);
}
var fileFormatException = new FileFormatException(message, exception);
fileFormatException.WithFilePath(path);
if (exception.BytePositionInLine is not null && exception.LineNumber is not null)
{
fileFormatException.WithLineInfo(exception.LineNumber, exception.BytePositionInLine);
}

return fileFormatException;
}
}
}
Loading