-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #73372 from CyrusNajmabadi/runOopByDefault
- Loading branch information
Showing
16 changed files
with
191 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
src/Workspaces/Core/Portable/Serialization/SerializedMetadataReference.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System.Collections.Generic; | ||
using System.Collections.Immutable; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using Microsoft.CodeAnalysis.Host; | ||
using Roslyn.Utilities; | ||
|
||
namespace Microsoft.CodeAnalysis.Serialization; | ||
|
||
using static TemporaryStorageService; | ||
|
||
internal partial class SerializerService | ||
{ | ||
[DebuggerDisplay("{" + nameof(Display) + ",nq}")] | ||
private sealed class SerializedMetadataReference : PortableExecutableReference, ISupportTemporaryStorage | ||
{ | ||
private readonly Metadata _metadata; | ||
private readonly ImmutableArray<TemporaryStorageStreamHandle> _storageHandles; | ||
private readonly DocumentationProvider _provider; | ||
|
||
public IReadOnlyList<ITemporaryStorageStreamHandle> StorageHandles => _storageHandles; | ||
|
||
public SerializedMetadataReference( | ||
MetadataReferenceProperties properties, | ||
string? fullPath, | ||
Metadata metadata, | ||
ImmutableArray<TemporaryStorageStreamHandle> storageHandles, | ||
DocumentationProvider initialDocumentation) | ||
: base(properties, fullPath, initialDocumentation) | ||
{ | ||
Contract.ThrowIfTrue(storageHandles.IsDefault); | ||
_metadata = metadata; | ||
_storageHandles = storageHandles; | ||
|
||
_provider = initialDocumentation; | ||
} | ||
|
||
protected override DocumentationProvider CreateDocumentationProvider() | ||
{ | ||
// this uses documentation provider given at the constructor | ||
throw ExceptionUtilities.Unreachable(); | ||
} | ||
|
||
protected override Metadata GetMetadataImpl() | ||
=> _metadata; | ||
|
||
protected override PortableExecutableReference WithPropertiesImpl(MetadataReferenceProperties properties) | ||
=> new SerializedMetadataReference(properties, FilePath, _metadata, _storageHandles, _provider); | ||
|
||
public override string ToString() | ||
{ | ||
var metadata = TryGetMetadata(this); | ||
var modules = GetModules(metadata); | ||
|
||
return $""" | ||
{nameof(SerializedMetadataReference)} | ||
FilePath={this.FilePath} | ||
Kind={this.Properties.Kind} | ||
Aliases={this.Properties.Aliases.Join(",")} | ||
EmbedInteropTypes={this.Properties.EmbedInteropTypes} | ||
MetadataKind={metadata switch { null => "null", AssemblyMetadata => "assembly", ModuleMetadata => "module", _ => metadata.GetType().Name }} | ||
Guids={modules.Select(m => GetMetadataGuid(m).ToString()).Join(",")} | ||
"""; | ||
|
||
static ImmutableArray<ModuleMetadata> GetModules(Metadata? metadata) | ||
{ | ||
if (metadata is AssemblyMetadata assemblyMetadata) | ||
{ | ||
if (TryGetModules(assemblyMetadata, out var modules)) | ||
return modules; | ||
} | ||
else if (metadata is ModuleMetadata moduleMetadata) | ||
{ | ||
return [moduleMetadata]; | ||
} | ||
|
||
return []; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.