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 line/column information to invalid project exception #11232

Merged
Changes from 1 commit
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
32 changes: 20 additions & 12 deletions src/Build/Construction/Solution/SolutionFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -302,28 +302,36 @@ internal void ParseUsingNewParser()
{
ISolutionSerializer serializer = SolutionSerializers.GetSerializerByMoniker(FullPath);

if (serializer != null)
if (serializer == null)
{
ProjectFileErrorUtilities.ThrowInvalidProjectFile(
new BuildEventFileInfo(FullPath),
$"InvalidProjectFile",
$"No solution serializer was found for {FullPath}");
}
else
{
try
{
SolutionModel solutionModel = serializer.OpenAsync(FullPath, CancellationToken.None).Result;
SolutionModel solutionModel = serializer.OpenAsync(FullPath, CancellationToken.None).GetAwaiter().GetResult();
ReadSolutionModel(solutionModel);
}
catch (SolutionException solutionEx)
{
var errorLocation = ElementLocation.Create(FullPath, solutionEx.Line ?? 0, solutionEx.Column ?? 0);
ProjectFileErrorUtilities.ThrowInvalidProjectFile(
new BuildEventFileInfo(errorLocation),
"InvalidProjectFile",
solutionEx.Message);
YuliiaKovalova marked this conversation as resolved.
Show resolved Hide resolved
}
catch (Exception ex)
{
ProjectFileErrorUtilities.ThrowInvalidProjectFile(
new BuildEventFileInfo(FullPath),
$"InvalidProjectFile",
ex.ToString());
new BuildEventFileInfo(FullPath),
"InvalidProjectFile",
ex.ToString());
}
}
else if (serializer == null)
{
ProjectFileErrorUtilities.ThrowInvalidProjectFile(
new BuildEventFileInfo(FullPath),
$"InvalidProjectFile",
$"No solution serializer was found for {FullPath}");
}
}

/// <summary>
Expand Down