зеркало из https://github.com/dotnet/razor.git
Clean up Project|SolutionExtensions
This commit is contained in:
Родитель
5e72b6d3d9
Коммит
684af14712
|
@ -1,31 +1,18 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using Microsoft.AspNetCore.Razor;
|
||||
|
||||
namespace Microsoft.CodeAnalysis.Razor.Workspaces;
|
||||
namespace Microsoft.CodeAnalysis;
|
||||
|
||||
internal static class ProjectExtensions
|
||||
{
|
||||
internal static Document GetRequiredDocument(this Project project, DocumentId documentId)
|
||||
{
|
||||
if (project is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(project));
|
||||
}
|
||||
ArgHelper.ThrowIfNull(project);
|
||||
ArgHelper.ThrowIfNull(documentId);
|
||||
|
||||
if (documentId is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(documentId));
|
||||
}
|
||||
|
||||
var document = project.GetDocument(documentId);
|
||||
|
||||
if (document is null)
|
||||
{
|
||||
throw new InvalidOperationException($"The document {documentId} did not exist in {project.Name}");
|
||||
}
|
||||
|
||||
return document;
|
||||
return project.GetDocument(documentId)
|
||||
?? ThrowHelper.ThrowInvalidOperationException<Document>($"The document {documentId} did not exist in {project.Name}");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,15 +1,18 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using Microsoft.AspNetCore.Razor;
|
||||
|
||||
namespace Microsoft.CodeAnalysis.Razor.Workspaces;
|
||||
namespace Microsoft.CodeAnalysis;
|
||||
|
||||
internal static class SolutionExtensions
|
||||
{
|
||||
internal static Project GetRequiredProject(this Solution solution, ProjectId projectId)
|
||||
{
|
||||
ArgHelper.ThrowIfNull(solution);
|
||||
ArgHelper.ThrowIfNull(projectId);
|
||||
|
||||
return solution.GetProject(projectId)
|
||||
?? throw new InvalidOperationException($"The projectId {projectId} did not exist in {solution}.");
|
||||
?? ThrowHelper.ThrowInvalidOperationException<Project>($"The projectId {projectId} did not exist in {solution}.");
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче