-
Notifications
You must be signed in to change notification settings - Fork 91
Expand file tree
/
Copy pathRuntimeComposition.cs
More file actions
548 lines (443 loc) · 25.1 KB
/
Copy pathRuntimeComposition.cs
File metadata and controls
548 lines (443 loc) · 25.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
namespace Microsoft.VisualStudio.Composition
{
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualStudio.Composition.Reflection;
public class RuntimeComposition : IEquatable<RuntimeComposition>
{
private readonly ImmutableHashSet<RuntimePart> parts;
private readonly IReadOnlyDictionary<TypeRef, RuntimePart> partsByType;
private readonly IReadOnlyDictionary<string, IReadOnlyCollection<RuntimeExport>> exportsByContractName;
private readonly IReadOnlyDictionary<TypeRef, RuntimeExport> metadataViewsAndProviders;
private RuntimeComposition(IEnumerable<RuntimePart> parts, IReadOnlyDictionary<TypeRef, RuntimeExport> metadataViewsAndProviders, Resolver resolver)
{
Requires.NotNull(parts, nameof(parts));
Requires.NotNull(metadataViewsAndProviders, nameof(metadataViewsAndProviders));
Requires.NotNull(resolver, nameof(resolver));
this.parts = ImmutableHashSet.CreateRange(parts);
var invalidArgExceptionMsg = "Invalid arguments passed to generate runtime composition.";
var invalidArgExceptionData = "InvalidCompositionException";
if (this.parts.Count == 0)
{
var exception = new ArgumentException(invalidArgExceptionMsg, nameof(parts));
exception.Data.Add(invalidArgExceptionData, true);
throw exception;
}
if (metadataViewsAndProviders.Count == 0)
{
var exception = new ArgumentException(invalidArgExceptionMsg, nameof(metadataViewsAndProviders));
exception.Data.Add(invalidArgExceptionData, true);
throw exception;
}
this.metadataViewsAndProviders = metadataViewsAndProviders;
this.Resolver = resolver;
this.partsByType = this.parts.ToDictionary(p => p.TypeRef, this.parts.Count);
var exports =
from part in this.parts
from export in part.Exports
group export by export.ContractName into exportsByContract
select exportsByContract;
this.exportsByContractName = exports.ToDictionary(
e => e.Key,
e => (IReadOnlyCollection<RuntimeExport>)e.ToImmutableArray());
}
public IReadOnlyCollection<RuntimePart> Parts
{
get { return this.parts; }
}
public IReadOnlyDictionary<TypeRef, RuntimeExport> MetadataViewsAndProviders
{
get { return this.metadataViewsAndProviders; }
}
internal Resolver Resolver { get; }
public static RuntimeComposition CreateRuntimeComposition(CompositionConfiguration configuration)
{
Requires.NotNull(configuration, nameof(configuration));
// PERF/memory tip: We could create all RuntimeExports first, and then reuse them at each import site.
var parts = configuration.Parts.Select(part => CreateRuntimePart(part, configuration));
var metadataViewsAndProviders = ImmutableDictionary.CreateRange(
from viewAndProvider in configuration.MetadataViewsAndProviders
let viewTypeRef = TypeRef.Get(viewAndProvider.Key, configuration.Resolver)
let runtimeExport = CreateRuntimeExport(viewAndProvider.Value, configuration.Resolver)
select new KeyValuePair<TypeRef, RuntimeExport>(viewTypeRef, runtimeExport));
return new RuntimeComposition(parts, metadataViewsAndProviders, configuration.Resolver);
}
public static RuntimeComposition CreateRuntimeComposition(IEnumerable<RuntimePart> parts, IReadOnlyDictionary<TypeRef, RuntimeExport> metadataViewsAndProviders, Resolver resolver)
{
return new RuntimeComposition(parts, metadataViewsAndProviders, resolver);
}
public IExportProviderFactory CreateExportProviderFactory()
{
return new RuntimeExportProviderFactory(this);
}
public IReadOnlyCollection<RuntimeExport> GetExports(string contractName)
{
IReadOnlyCollection<RuntimeExport>? exports;
if (this.exportsByContractName.TryGetValue(contractName, out exports))
{
return exports;
}
return ImmutableList<RuntimeExport>.Empty;
}
public RuntimePart GetPart(RuntimeExport export)
{
Requires.NotNull(export, nameof(export));
return this.partsByType[export.DeclaringTypeRef];
}
public RuntimePart GetPart(TypeRef partType)
{
Requires.NotNull(partType, nameof(partType));
return this.partsByType[partType];
}
public override bool Equals(object? obj)
{
return this.Equals(obj as RuntimeComposition);
}
public override int GetHashCode()
{
int hashCode = this.parts.Count;
foreach (var part in this.parts)
{
hashCode += part.GetHashCode();
}
return hashCode;
}
public bool Equals(RuntimeComposition? other)
{
if (other == null)
{
return false;
}
return this.parts.SetEquals(other.parts)
&& ByValueEquality.Dictionary<TypeRef, RuntimeExport>().Equals(this.metadataViewsAndProviders, other.metadataViewsAndProviders);
}
internal static string GetDiagnosticLocation(RuntimeImport import)
{
Requires.NotNull(import, nameof(import));
return string.Format(
CultureInfo.CurrentCulture,
"{0}.{1}",
import.DeclaringTypeRef?.Resolve().FullName,
import.ImportingMember == null ? ("ctor(" + import.ImportingParameter!.Name + ")") : import.ImportingMember.Name);
}
internal static string GetDiagnosticLocation(RuntimeExport export)
{
Requires.NotNull(export, nameof(export));
if (export.Member != null)
{
return string.Format(
CultureInfo.CurrentCulture,
"{0}.{1}",
export.DeclaringTypeRef.Resolve().FullName,
export.Member.Name);
}
else
{
return export.DeclaringTypeRef.Resolve().FullName ?? "<no name>";
}
}
private static RuntimePart CreateRuntimePart(ComposedPart part, CompositionConfiguration configuration)
{
Requires.NotNull(part, nameof(part));
var runtimePart = new RuntimePart(
part.Definition.TypeRef,
part.Definition.ImportingConstructorOrFactoryRef,
part.GetImportingConstructorImports().Select(kvp => CreateRuntimeImport(kvp.Key, kvp.Value, part.Resolver)).ToImmutableArray(),
part.Definition.ImportingMembers.Select(idb => CreateRuntimeImport(idb, part.SatisfyingExports[idb], part.Resolver)).ToImmutableArray(),
part.Definition.ExportDefinitions.Select(ed => CreateRuntimeExport(ed.Value, part.Definition.TypeRef, ed.Key, part.Resolver)).ToImmutableArray(),
part.Definition.OnImportsSatisfiedMethodRefs,
part.Definition.IsShared ? configuration.GetEffectiveSharingBoundary(part.Definition) : null);
return runtimePart;
}
private static RuntimeImport CreateRuntimeImport(ImportDefinitionBinding importDefinitionBinding, IReadOnlyList<ExportDefinitionBinding> satisfyingExports, Resolver resolver)
{
Requires.NotNull(importDefinitionBinding, nameof(importDefinitionBinding));
Requires.NotNull(satisfyingExports, nameof(satisfyingExports));
var runtimeExports = satisfyingExports.Select(export => CreateRuntimeExport(export, resolver)).ToImmutableArray();
if (importDefinitionBinding.ImportingMemberRef != null)
{
return new RuntimeImport(
importDefinitionBinding.ImportingMemberRef,
importDefinitionBinding.ImportingSiteTypeRef,
importDefinitionBinding.ImportingSiteTypeWithoutCollectionRef,
importDefinitionBinding.ImportDefinition.Cardinality,
runtimeExports,
PartCreationPolicyConstraint.IsNonSharedInstanceRequired(importDefinitionBinding.ImportDefinition),
importDefinitionBinding.IsExportFactory,
importDefinitionBinding.ImportDefinition.Metadata,
importDefinitionBinding.ImportDefinition.ExportFactorySharingBoundaries);
}
else
{
return new RuntimeImport(
importDefinitionBinding.ImportingParameterRef!,
importDefinitionBinding.ImportingSiteTypeRef,
importDefinitionBinding.ImportingSiteTypeWithoutCollectionRef,
importDefinitionBinding.ImportDefinition.Cardinality,
runtimeExports,
PartCreationPolicyConstraint.IsNonSharedInstanceRequired(importDefinitionBinding.ImportDefinition),
importDefinitionBinding.IsExportFactory,
importDefinitionBinding.ImportDefinition.Metadata,
importDefinitionBinding.ImportDefinition.ExportFactorySharingBoundaries);
}
}
private static RuntimeExport CreateRuntimeExport(ExportDefinition exportDefinition, TypeRef partTypeRef, MemberRef? exportingMemberRef, Resolver resolver)
{
Requires.NotNull(exportDefinition, nameof(exportDefinition));
return new RuntimeExport(
exportDefinition.ContractName,
partTypeRef,
exportingMemberRef,
exportDefinition.Metadata);
}
private static RuntimeExport CreateRuntimeExport(ExportDefinitionBinding exportDefinitionBinding, Resolver resolver)
{
Requires.NotNull(exportDefinitionBinding, nameof(exportDefinitionBinding));
Requires.NotNull(resolver, nameof(resolver));
var partDefinitionTypeRef = exportDefinitionBinding.PartDefinition.TypeRef;
return CreateRuntimeExport(
exportDefinitionBinding.ExportDefinition,
partDefinitionTypeRef,
exportDefinitionBinding.ExportingMemberRef,
resolver);
}
[DebuggerDisplay("{" + nameof(DebuggerDisplay) + ",nq}")]
public class RuntimePart : IEquatable<RuntimePart>
{
public RuntimePart(
TypeRef type,
MethodRef? importingConstructor,
IReadOnlyList<RuntimeImport> importingConstructorArguments,
IReadOnlyList<RuntimeImport> importingMembers,
IReadOnlyList<RuntimeExport> exports,
IReadOnlyList<MethodRef> onImportsSatisfiedMethods,
string? sharingBoundary)
{
this.TypeRef = type;
this.ImportingConstructorOrFactoryMethodRef = importingConstructor;
this.ImportingConstructorArguments = importingConstructorArguments;
this.ImportingMembers = importingMembers;
this.Exports = exports;
this.OnImportsSatisfiedMethodRefs = onImportsSatisfiedMethods;
this.SharingBoundary = sharingBoundary;
}
public TypeRef TypeRef { get; private set; }
public MethodRef? ImportingConstructorOrFactoryMethodRef { get; private set; }
public MethodBase? ImportingConstructorOrFactoryMethod => this.ImportingConstructorOrFactoryMethodRef?.MethodBase;
public IReadOnlyList<RuntimeImport> ImportingConstructorArguments { get; private set; }
public IReadOnlyList<RuntimeImport> ImportingMembers { get; private set; }
public IReadOnlyList<RuntimeExport> Exports { get; set; }
public string? SharingBoundary { get; private set; }
public bool IsShared => this.SharingBoundary != null;
public bool IsInstantiable => this.ImportingConstructorOrFactoryMethodRef != null;
public IReadOnlyList<MethodRef> OnImportsSatisfiedMethodRefs { get; }
private string? DebuggerDisplay => this.TypeRef.FullName;
public override bool Equals(object? obj) => this.Equals(obj as RuntimePart);
public override int GetHashCode() => this.TypeRef.GetHashCode();
public bool Equals(RuntimePart? other)
{
if (other == null)
{
return false;
}
bool result = EqualityComparer<TypeRef>.Default.Equals(this.TypeRef, other.TypeRef)
&& EqualityComparer<MethodRef?>.Default.Equals(this.ImportingConstructorOrFactoryMethodRef, other.ImportingConstructorOrFactoryMethodRef)
&& this.ImportingConstructorArguments.SequenceEqual(other.ImportingConstructorArguments)
&& ByValueEquality.EquivalentIgnoreOrder<RuntimeImport>().Equals(this.ImportingMembers, other.ImportingMembers)
&& ByValueEquality.EquivalentIgnoreOrder<RuntimeExport>().Equals(this.Exports, other.Exports)
&& this.OnImportsSatisfiedMethodRefs.SequenceEqual(other.OnImportsSatisfiedMethodRefs, EqualityComparer<MethodRef?>.Default)
&& this.SharingBoundary == other.SharingBoundary;
return result;
}
}
[DebuggerDisplay("{" + nameof(ImportingSiteElementType) + "}")]
public class RuntimeImport : IEquatable<RuntimeImport>
{
private ParameterInfo? importingParameter;
private MemberInfo? importingMember;
private RuntimeImport(TypeRef importingSiteTypeRef, TypeRef importingSiteTypeWithoutCollectionRef, ImportCardinality cardinality, IReadOnlyList<RuntimeExport> satisfyingExports, bool isNonSharedInstanceRequired, bool isExportFactory, IReadOnlyDictionary<string, object?> metadata, IReadOnlyCollection<string> exportFactorySharingBoundaries)
{
Requires.NotNull(importingSiteTypeRef, nameof(importingSiteTypeRef));
Requires.NotNull(importingSiteTypeWithoutCollectionRef, nameof(importingSiteTypeWithoutCollectionRef));
Requires.NotNull(satisfyingExports, nameof(satisfyingExports));
this.Cardinality = cardinality;
this.SatisfyingExports = satisfyingExports;
this.IsNonSharedInstanceRequired = isNonSharedInstanceRequired;
this.IsExportFactory = isExportFactory;
this.Metadata = metadata;
this.ImportingSiteTypeRef = importingSiteTypeRef;
this.ImportingSiteTypeWithoutCollectionRef = importingSiteTypeWithoutCollectionRef;
this.ExportFactorySharingBoundaries = exportFactorySharingBoundaries;
}
public RuntimeImport(MemberRef? importingMemberRef, TypeRef importingSiteTypeRef, TypeRef importingSiteTypeWithoutCollectionRef, ImportCardinality cardinality, IReadOnlyList<RuntimeExport> satisfyingExports, bool isNonSharedInstanceRequired, bool isExportFactory, IReadOnlyDictionary<string, object?> metadata, IReadOnlyCollection<string> exportFactorySharingBoundaries)
: this(importingSiteTypeRef, importingSiteTypeWithoutCollectionRef, cardinality, satisfyingExports, isNonSharedInstanceRequired, isExportFactory, metadata, exportFactorySharingBoundaries)
{
this.ImportingMemberRef = importingMemberRef;
}
public RuntimeImport(ParameterRef importingParameterRef, TypeRef importingSiteTypeRef, TypeRef importingSiteTypeWithoutCollectionRef, ImportCardinality cardinality, IReadOnlyList<RuntimeExport> satisfyingExports, bool isNonSharedInstanceRequired, bool isExportFactory, IReadOnlyDictionary<string, object?> metadata, IReadOnlyCollection<string> exportFactorySharingBoundaries)
: this(importingSiteTypeRef, importingSiteTypeWithoutCollectionRef, cardinality, satisfyingExports, isNonSharedInstanceRequired, isExportFactory, metadata, exportFactorySharingBoundaries)
{
Requires.NotNull(importingParameterRef, nameof(importingParameterRef));
this.ImportingParameterRef = importingParameterRef;
}
/// <summary>
/// Gets the importing member. May be empty if the import site is an importing constructor parameter.
/// </summary>
public MemberRef? ImportingMemberRef { get; private set; }
/// <summary>
/// Gets the importing parameter. May be empty if the import site is an importing field or property.
/// </summary>
public ParameterRef? ImportingParameterRef { get; private set; }
public TypeRef ImportingSiteTypeRef { get; private set; }
public ImportCardinality Cardinality { get; private set; }
public IReadOnlyCollection<RuntimeExport> SatisfyingExports { get; private set; }
public bool IsExportFactory { get; private set; }
public bool IsNonSharedInstanceRequired { get; private set; }
public IReadOnlyDictionary<string, object?> Metadata { get; private set; }
public Type? ExportFactory
{
get
{
return this.IsExportFactory
? this.ImportingSiteTypeWithoutCollection
: null;
}
}
/// <summary>
/// Gets the sharing boundaries created when the export factory is used.
/// </summary>
public IReadOnlyCollection<string> ExportFactorySharingBoundaries { get; private set; }
public MemberInfo? ImportingMember => this.importingMember ?? (this.importingMember = this.ImportingMemberRef?.MemberInfo);
public ParameterInfo? ImportingParameter => this.importingParameter ?? (this.importingParameter = this.ImportingParameterRef?.ParameterInfo);
public bool IsLazy => this.ImportingSiteTypeWithoutCollectionRef.IsAnyLazyType();
public Type ImportingSiteType => this.ImportingSiteTypeRef.ResolvedType;
public Type ImportingSiteTypeWithoutCollection => this.ImportingSiteTypeWithoutCollectionRef.ResolvedType;
public TypeRef ImportingSiteTypeWithoutCollectionRef { get; private set; }
/// <summary>
/// Gets the type of the member, with the ImportMany collection and Lazy/ExportFactory stripped off, when present.
/// </summary>
public Type ImportingSiteElementType => PartDiscovery.GetTypeIdentityFromImportingType(this.ImportingSiteType, this.Cardinality == ImportCardinality.ZeroOrMore);
public Type? MetadataType
{
get
{
return this.IsLazy && this.ImportingSiteTypeWithoutCollection.GenericTypeArguments.Length == 2
? this.ImportingSiteTypeWithoutCollection.GenericTypeArguments[1]
: null;
}
}
public TypeRef DeclaringTypeRef
{
get
{
return this.ImportingMemberRef?.DeclaringType ?? this.ImportingParameterRef?.DeclaringType ?? throw Assumes.NotReachable();
}
}
internal Func<AssemblyName, Func<object?>, object, object>? LazyFactory
{
get
{
if (!this.IsLazy)
{
return null;
}
Type[] lazyTypeArgs = this.ImportingSiteTypeWithoutCollection.GenericTypeArguments;
return LazyServices.CreateStronglyTypedLazyFactory(this.ImportingSiteElementType, lazyTypeArgs.Length > 1 ? lazyTypeArgs[1] : null);
}
}
public override int GetHashCode() => this.ImportingMemberRef?.GetHashCode() ?? 0;
public override bool Equals(object? obj) => this.Equals(obj as RuntimeImport);
public bool Equals(RuntimeImport? other)
{
if (other == null)
{
return false;
}
bool result = EqualityComparer<TypeRef>.Default.Equals(this.ImportingSiteTypeRef, other.ImportingSiteTypeRef)
&& this.Cardinality == other.Cardinality
&& ByValueEquality.EquivalentIgnoreOrder<RuntimeExport>().Equals(this.SatisfyingExports, other.SatisfyingExports)
&& this.IsNonSharedInstanceRequired == other.IsNonSharedInstanceRequired
&& ByValueEquality.Metadata.Equals(this.Metadata, other.Metadata)
&& ByValueEquality.EquivalentIgnoreOrder<string>().Equals(this.ExportFactorySharingBoundaries, other.ExportFactorySharingBoundaries)
&& EqualityComparer<MemberRef?>.Default.Equals(this.ImportingMemberRef, other.ImportingMemberRef)
&& EqualityComparer<ParameterRef?>.Default.Equals(this.ImportingParameterRef, other.ImportingParameterRef);
return result;
}
}
public class RuntimeExport : IEquatable<RuntimeExport>
{
private MemberInfo? member;
private TypeRef? exportedValueTypeRef;
public RuntimeExport(string contractName, TypeRef declaringTypeRef, MemberRef? memberRef, IReadOnlyDictionary<string, object?> metadata)
{
Requires.NotNullOrEmpty(contractName, nameof(contractName));
Requires.NotNull(declaringTypeRef, nameof(declaringTypeRef));
Requires.NotNull(metadata, nameof(metadata));
this.ContractName = contractName;
this.DeclaringTypeRef = declaringTypeRef;
this.MemberRef = memberRef;
this.Metadata = metadata;
}
public RuntimeExport(string contractName, TypeRef declaringTypeRef, MemberRef? memberRef, TypeRef? exportedValueTypeRef, IReadOnlyDictionary<string, object?> metadata)
{
Requires.NotNullOrEmpty(contractName, nameof(contractName));
Requires.NotNull(declaringTypeRef, nameof(declaringTypeRef));
Requires.NotNull(metadata, nameof(metadata));
this.ContractName = contractName;
this.DeclaringTypeRef = declaringTypeRef;
this.MemberRef = memberRef;
this.exportedValueTypeRef = exportedValueTypeRef;
this.Metadata = metadata;
}
public string ContractName { get; private set; }
public TypeRef DeclaringTypeRef { get; private set; }
public MemberRef? MemberRef { get; private set; }
public TypeRef ExportedValueTypeRef
{
get
{
if (this.MemberRef == null)
{
return this.DeclaringTypeRef;
}
if (this.exportedValueTypeRef == null)
{
this.exportedValueTypeRef = ReflectionHelpers.GetExportedValueTypeRef(this.DeclaringTypeRef, this.MemberRef);
}
return this.exportedValueTypeRef;
}
}
public Type ExportedValueType
{
get { return this.ExportedValueTypeRef.ResolvedType; }
}
public IReadOnlyDictionary<string, object?> Metadata { get; private set; }
public MemberInfo? Member => this.member ?? (this.member = this.MemberRef?.MemberInfo);
public override int GetHashCode() => this.ContractName.GetHashCode() + this.DeclaringTypeRef.GetHashCode();
public override bool Equals(object? obj) => this.Equals(obj as RuntimeExport);
public bool Equals(RuntimeExport? other)
{
if (other == null)
{
return false;
}
bool result = this.ContractName == other.ContractName
&& EqualityComparer<TypeRef>.Default.Equals(this.DeclaringTypeRef, other.DeclaringTypeRef)
&& EqualityComparer<MemberRef?>.Default.Equals(this.MemberRef, other.MemberRef)
&& EqualityComparer<TypeRef>.Default.Equals(this.ExportedValueTypeRef, other.ExportedValueTypeRef)
&& ByValueEquality.Metadata.Equals(this.Metadata, other.Metadata);
return result;
}
}
}
}