Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
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
27 changes: 27 additions & 0 deletions src/WinRT.Generator.Core/Extensions/SignatureComparerExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using AsmResolver.DotNet.Signatures;

namespace WindowsRuntime.Generator;

/// <summary>
/// Extensions for <see cref="SignatureComparer"/>.
/// </summary>
internal static class SignatureComparerExtensions
{
/// <summary>
/// Backing field for the <see cref="IgnoreVersion"/> extension property.
/// </summary>
private static readonly SignatureComparer IgnoreVersion = new(SignatureComparisonFlags.VersionAgnostic);

extension(SignatureComparer)
{
/// <summary>
/// Gets a shared, version-agnostic <see cref="SignatureComparer"/>, suitable for comparing
/// AsmResolver entities (e.g. as the <see cref="System.Collections.Generic.IEqualityComparer{T}"/>
/// for a <see cref="System.Collections.Generic.HashSet{T}"/> of <see cref="AsmResolver.DotNet.TypeDefinition"/>).
/// </summary>
public static SignatureComparer IgnoreVersion => IgnoreVersion;
}
}
3 changes: 3 additions & 0 deletions src/WinRT.Generator.Core/WinRT.Generator.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,8 @@
<InternalsVisibleTo Include="cswinrtprojectiongen" />
<InternalsVisibleTo Include="cswinrtprojectionrefgen" />
<InternalsVisibleTo Include="cswinrtwinmdgen" />

<!-- The projection writer library consumes shared helpers (e.g. SignatureComparer.IgnoreVersion). -->
<InternalsVisibleTo Include="WinRT.Projection.Writer" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using AsmResolver.DotNet;
using AsmResolver.DotNet.Signatures;
using AsmResolver.PE.DotNet.Metadata.Tables;
using WindowsRuntime.Generator;
using WindowsRuntime.InteropGenerator.Factories;
using WindowsRuntime.InteropGenerator.Generation;
using WindowsRuntime.InteropGenerator.Helpers;
Expand Down Expand Up @@ -533,4 +534,4 @@ public static void ImplType(
implType.Properties.Add(mapChangedTableProperty);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using AsmResolver.DotNet;
using AsmResolver.DotNet.Signatures;
using AsmResolver.PE.DotNet.Metadata.Tables;
using WindowsRuntime.Generator;
using WindowsRuntime.InteropGenerator.Factories;
using WindowsRuntime.InteropGenerator.Generation;
using WindowsRuntime.InteropGenerator.Helpers;
Expand Down Expand Up @@ -521,4 +522,4 @@ public static void ImplType(
emitState.TrackTypeDefinition(implType, vectorType, "Impl");
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using AsmResolver.DotNet;
using AsmResolver.DotNet.Signatures;
using WindowsRuntime.Generator;
using WindowsRuntime.InteropGenerator.Errors;
using WindowsRuntime.InteropGenerator.Generation;
using WindowsRuntime.InteropGenerator.Helpers;
Expand Down Expand Up @@ -636,4 +637,4 @@ private static void TryTrackManagedGenericTypeInstance(
interopReferences: interopReferences,
module: module);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Linq;
using AsmResolver.DotNet;
using AsmResolver.DotNet.Signatures;
using WindowsRuntime.Generator;
using WindowsRuntime.InteropGenerator.Errors;
using WindowsRuntime.InteropGenerator.Generation;
using WindowsRuntime.InteropGenerator.Helpers;
Expand Down Expand Up @@ -562,4 +563,4 @@ private static bool TryAddExposedInterfaceType(

return true;
}
}
}
3 changes: 2 additions & 1 deletion src/WinRT.Interop.Generator/Extensions/ComExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Diagnostics.CodeAnalysis;
using AsmResolver.DotNet;
using AsmResolver.DotNet.Signatures;
using WindowsRuntime.Generator;
using WindowsRuntime.InteropGenerator.References;

namespace WindowsRuntime.InteropGenerator;
Expand Down Expand Up @@ -72,4 +73,4 @@ public bool TryGetInterfaceInformationType(InteropReferences interopReferences,
return true;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using AsmResolver;
using AsmResolver.DotNet;
using AsmResolver.DotNet.Signatures;
using WindowsRuntime.Generator;

namespace WindowsRuntime.InteropGenerator;

Expand Down Expand Up @@ -100,4 +101,4 @@ public static bool HasCustomAttribute(this IHasCustomAttribute member, ITypeDesc
{
return TryGetCustomAttribute(member, attributeType, out _);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using AsmResolver.DotNet;
using AsmResolver.DotNet.Signatures;
using AsmResolver.PE.DotNet.Metadata.Tables;
using WindowsRuntime.Generator;
using WindowsRuntime.InteropGenerator.Helpers;
using WindowsRuntime.InteropGenerator.Visitors;

Expand Down Expand Up @@ -304,4 +305,4 @@ public static IEnumerable<ModuleDefinition> OrderByFullyQualifiedName(this IEnum
{
return modules.Order(ModuleDefinitionComparer.Instance);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,8 @@ namespace WindowsRuntime.InteropGenerator;
/// </summary>
internal static class SignatureComparerExtensions
{
#pragma warning disable IDE0052 // TODO: remove this once Roslyn bug is fixed
/// <summary>
/// Backing field for <see cref="get_IgnoreVersion"/>.
/// </summary>
private static readonly SignatureComparer IgnoreVersion = new(SignatureComparisonFlags.VersionAgnostic);
#pragma warning restore IDE0052

extension(SignatureComparer comparer)
{
/// <summary>
/// An immutable default instance of <see cref="SignatureComparer"/>, with <see cref="SignatureComparisonFlags.VersionAgnostic"/>.
/// </summary>
public static SignatureComparer IgnoreVersion => IgnoreVersion;

/// <summary>
/// Creates an <see cref="IEqualityComparer{T}"/> instance for a pair of <see cref="TypeSignature"/> values.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using AsmResolver.DotNet;
using AsmResolver.DotNet.Signatures;
using AsmResolver.PE.DotNet.Metadata.Tables;
using WindowsRuntime.Generator;

#pragma warning disable IDE0046

Expand Down Expand Up @@ -344,4 +345,4 @@ public IEnumerable<GenericInstanceTypeSignature> EnumerateGenericInstanceInterfa
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using AsmResolver.DotNet;
using AsmResolver.DotNet.Signatures;
using AsmResolver.PE.DotNet.Metadata.Tables;
using WindowsRuntime.Generator;
using WindowsRuntime.InteropGenerator.References;

#pragma warning disable IDE0046
Expand Down Expand Up @@ -1186,4 +1187,4 @@ file static class WellKnownMetadataNames
/// The <c>"WindowsRuntimeComponentAssemblyAttribute"</c> text.
/// </summary>
public static readonly Utf8String WindowsRuntimeComponentAssemblyAttribute = "WindowsRuntimeComponentAssemblyAttribute"u8;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using AsmResolver.DotNet.Signatures;
using AsmResolver.PE.DotNet.Cil;
using AsmResolver.PE.DotNet.Metadata.Tables;
using WindowsRuntime.Generator;
using WindowsRuntime.InteropGenerator.Generation;
using WindowsRuntime.InteropGenerator.References;
using static AsmResolver.PE.DotNet.Cil.CilOpCodes;
Expand Down Expand Up @@ -512,4 +513,4 @@ public static MethodDefinition Split(
return splitMethod;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using AsmResolver.DotNet.Signatures;
using AsmResolver.PE.DotNet.Cil;
using AsmResolver.PE.DotNet.Metadata.Tables;
using WindowsRuntime.Generator;
using WindowsRuntime.InteropGenerator.Generation;
using WindowsRuntime.InteropGenerator.References;
using static AsmResolver.PE.DotNet.Cil.CilOpCodes;
Expand Down Expand Up @@ -493,4 +494,4 @@ _ when elementType.IsTypeOfException(interopReferences) => interopReferences.IRe
return getManyImplMethod;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using AsmResolver.DotNet;
using AsmResolver.DotNet.Signatures;
using AsmResolver.PE;
using WindowsRuntime.Generator;
using WindowsRuntime.Generator.Errors;
using WindowsRuntime.Generator.Extensions;
using WindowsRuntime.Generator.References;
Expand Down Expand Up @@ -618,4 +619,4 @@ private static string[] GetAssembliesToProcess(InteropGeneratorArgs args)

return [.. assembliesToProcess];
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Diagnostics.CodeAnalysis;
using AsmResolver.DotNet;
using AsmResolver.DotNet.Signatures;
using WindowsRuntime.Generator;
using WindowsRuntime.InteropGenerator.Errors;
using WindowsRuntime.InteropGenerator.Models;

Expand Down Expand Up @@ -572,4 +573,4 @@ private void ThrowIfReadOnly()
throw WellKnownInteropExceptions.DiscoveryStateChangeAfterMakeReadOnlyError();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using AsmResolver.DotNet.Code.Cil;
using AsmResolver.DotNet.Signatures;
using AsmResolver.PE.DotNet.Cil;
using WindowsRuntime.Generator;
using WindowsRuntime.InteropGenerator.Errors;
using WindowsRuntime.InteropGenerator.Models;

Expand Down Expand Up @@ -394,4 +395,4 @@ private void ThrowIfReadOnly()
throw WellKnownInteropExceptions.EmitStateChangeAfterMakeReadOnlyError();
}
}
}
}
1 change: 1 addition & 0 deletions src/WinRT.Interop.Generator/Helpers/TypeExclusions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using AsmResolver.DotNet;
using AsmResolver.DotNet.Signatures;
using WindowsRuntime.Generator;
using WindowsRuntime.InteropGenerator.References;

namespace WindowsRuntime.InteropGenerator.Helpers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Diagnostics.CodeAnalysis;
using AsmResolver.DotNet;
using AsmResolver.DotNet.Signatures;
using WindowsRuntime.Generator;
using WindowsRuntime.InteropGenerator.References;

namespace WindowsRuntime.InteropGenerator.Helpers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using AsmResolver.DotNet.Signatures;
using WindowsRuntime.Generator;

namespace WindowsRuntime.InteropGenerator.Models;

Expand Down Expand Up @@ -122,4 +123,4 @@ public TypeSignatureEquatableSet MoveToEquatableSet()
return new(set);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using AsmResolver.DotNet.Signatures;
using WindowsRuntime.Generator;
using WindowsRuntime.InteropGenerator.Helpers;

namespace WindowsRuntime.InteropGenerator.Models;
Expand Down Expand Up @@ -220,4 +221,4 @@ IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Collections.Generic;
using AsmResolver.DotNet;
using AsmResolver.DotNet.Signatures;
using WindowsRuntime.Generator;
using WindowsRuntime.InteropGenerator.Errors;
using WindowsRuntime.InteropGenerator.Factories;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using AsmResolver.DotNet;
using AsmResolver.DotNet.Signatures;
using AsmResolver.PE.DotNet.Metadata.Tables;
using WindowsRuntime.Generator;
using WindowsRuntime.InteropGenerator.Factories;
using WindowsRuntime.InteropGenerator.Generation;
using WindowsRuntime.InteropGenerator.References;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using AsmResolver.DotNet;
using AsmResolver.DotNet.Code.Cil;
using AsmResolver.DotNet.Signatures;
using WindowsRuntime.Generator;
using WindowsRuntime.InteropGenerator.Generation;
using WindowsRuntime.InteropGenerator.Models;
using WindowsRuntime.InteropGenerator.References;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using AsmResolver.DotNet.Collections;
using AsmResolver.DotNet.Signatures;
using AsmResolver.PE.DotNet.Cil;
using WindowsRuntime.Generator;
using WindowsRuntime.InteropGenerator.Errors;
using WindowsRuntime.InteropGenerator.Generation;
using WindowsRuntime.InteropGenerator.References;
Expand Down Expand Up @@ -116,4 +117,4 @@ public static void RewriteMethod(
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using AsmResolver.DotNet.Code.Cil;
using AsmResolver.DotNet.Signatures;
using AsmResolver.PE.DotNet.Cil;
using WindowsRuntime.Generator;
using WindowsRuntime.InteropGenerator.Errors;
using WindowsRuntime.InteropGenerator.Generation;
using WindowsRuntime.InteropGenerator.References;
Expand Down Expand Up @@ -99,4 +100,4 @@ public static void RewriteMethod(
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using AsmResolver.DotNet.Collections;
using AsmResolver.DotNet.Signatures;
using AsmResolver.PE.DotNet.Cil;
using WindowsRuntime.Generator;
using WindowsRuntime.InteropGenerator.Errors;
using WindowsRuntime.InteropGenerator.Generation;
using WindowsRuntime.InteropGenerator.References;
Expand Down Expand Up @@ -425,4 +426,4 @@ private static void RewriteBodyForTypeOfType(
});
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using AsmResolver.DotNet.Code.Cil;
using AsmResolver.DotNet.Signatures;
using AsmResolver.PE.DotNet.Cil;
using WindowsRuntime.Generator;
using WindowsRuntime.InteropGenerator.Errors;
using WindowsRuntime.InteropGenerator.Generation;
using WindowsRuntime.InteropGenerator.References;
Expand Down Expand Up @@ -221,4 +222,4 @@ private static void RewriteBody(
});
}
}
}
}
Loading