aspnetcore/src/Microsoft.AspNetCore.Razor..../CachingMetadataReference.cs

33 lines
1.0 KiB
C#

// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.CodeAnalysis;
namespace Microsoft.AspNetCore.Razor.Tools
{
internal sealed class CachingMetadataReference : PortableExecutableReference
{
private static readonly MetadataCache _metadataCache = new MetadataCache();
public CachingMetadataReference(string fullPath, MetadataReferenceProperties properties)
: base(properties, fullPath)
{
}
protected override DocumentationProvider CreateDocumentationProvider()
{
return DocumentationProvider.Default;
}
protected override Metadata GetMetadataImpl()
{
return _metadataCache.GetMetadata(FilePath);
}
protected override PortableExecutableReference WithPropertiesImpl(MetadataReferenceProperties properties)
{
return new CachingMetadataReference(FilePath, properties);
}
}
}