Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'EnableDefaultCustomTypeMappings' switch #1483

Merged
merged 20 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
8 changes: 7 additions & 1 deletion nuget/Microsoft.Windows.CsWinRT.targets
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,11 @@ $(CsWinRTInternalProjection)
<Import Project="$(MSBuildThisFileDirectory)Microsoft.Windows.CsWinRT.Authoring.targets" Condition="'$(CsWinRTComponent)' == 'true'"/>
<Import Project="$(MSBuildThisFileDirectory)Microsoft.Windows.CsWinRT.IIDOptimizer.targets" Condition="'$(CsWinRTIIDOptimizerOptOut)' != 'true'"/>

<!-- Default values for all custom CsWinRT runtimem feature switches -->
<!-- Default values for all custom CsWinRT runtime feature switches -->
<PropertyGroup>
<CsWinRTEnableDynamicObjectsSupport Condition="'$(CsWinRTEnableDynamicObjectsSupport)' == ''">true</CsWinRTEnableDynamicObjectsSupport>
<CsWinRTUseExceptionResourceKeys Condition="'$(CsWinRTUseExceptionResourceKeys)' == ''">false</CsWinRTUseExceptionResourceKeys>
<CsWinRTEnableDefaultCustomTypeMappings Condition="'$(CsWinRTEnableDefaultCustomTypeMappings)' == ''">true</CsWinRTEnableDefaultCustomTypeMappings>
</PropertyGroup>

<!--
Expand All @@ -255,6 +256,11 @@ $(CsWinRTInternalProjection)
<RuntimeHostConfigurationOption Include="CSWINRT_USE_EXCEPTION_RESOURCE_KEYS"
Value="$(CsWinRTUseExceptionResourceKeys)"
Trim="true" />

<!-- CSWINRT_ENABLE_DEFAULT_CUSTOM_TYPE_MAPPINGS switch -->
<RuntimeHostConfigurationOption Include="CSWINRT_ENABLE_DEFAULT_CUSTOM_TYPE_MAPPINGS"
Value="$(CsWinRTEnableDefaultCustomTypeMappings)"
Trim="true" />
</ItemGroup>

</Project>
3 changes: 2 additions & 1 deletion src/WinRT.Runtime/ApiCompatBaseline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ CannotMakeMemberNonVirtual : Member 'public System.Int32 WinRT.IObjectReference.
MembersMustExist : Member 'protected System.Boolean System.Boolean WinRT.IObjectReference.disposed' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'protected void WinRT.IObjectReference.Dispose(System.Boolean)' does not exist in the implementation but it does exist in the contract.
CannotChangeAttribute : Attribute 'System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute' on 'ABI.System.Type.FromAbi(ABI.System.Type)' changed from '[UnconditionalSuppressMessageAttribute("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification="Any types which are trimmed are not used by managed user code and there is fallback logic to handle that.")]' in the contract to '[UnconditionalSuppressMessageAttribute("ReflectionAnalysis", "IL2057", Justification="Any types which are trimmed are not used by managed user code and there is fallback logic to handle that.")]' in the implementation.
Total Issues: 16
MembersMustExist : Member 'public void WinRT.Projections.RegisterCustomAbiTypeMapping(System.Type, System.Type, System.String, System.Boolean)' does not exist in the implementation but it does exist in the contract.
Total Issues: 17
19 changes: 19 additions & 0 deletions src/WinRT.Runtime/Configuration/FeatureSwitches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ internal static class FeatureSwitches
/// </summary>
private const string UseExceptionResourceKeysPropertyName = "CSWINRT_USE_EXCEPTION_RESOURCE_KEYS";

/// <summary>
/// The configuration property name for <see cref="EnableDefaultCustomTypeMappings"/>.
/// </summary>
private const string EnableDefaultCustomTypeMappingsPropertyName = "CSWINRT_ENABLE_DEFAULT_CUSTOM_TYPE_MAPPINGS";

/// <summary>
/// The backing field for <see cref="IsDynamicObjectsSupportEnabled"/>.
/// </summary>
Expand All @@ -41,6 +46,11 @@ internal static class FeatureSwitches
/// </summary>
private static int _useExceptionResourceKeys;

/// <summary>
/// The backing field for <see cref="EnableDefaultCustomTypeMappings"/>.
/// </summary>
private static int _enableDefaultCustomTypeMappings;

/// <summary>
/// Gets a value indicating whether or not projections support for dynamic objects is enabled (defaults to <see langword="true"/>).
/// </summary>
Expand All @@ -59,6 +69,15 @@ public static bool UseExceptionResourceKeys
get => GetConfigurationValue(UseExceptionResourceKeysPropertyName, ref _useExceptionResourceKeys);
}

/// <summary>
/// Gets a value indicating whether or not <see cref="Projections"/> should initialize all default type mappings automatically (defaults to <see langword="true"/>).
/// </summary>
public static bool EnableDefaultCustomTypeMappings
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => GetConfigurationValue(EnableDefaultCustomTypeMappingsPropertyName, ref _enableDefaultCustomTypeMappings);
}

/// <summary>
/// Gets a configuration value for a specified property.
/// </summary>
Expand Down
4 changes: 4 additions & 0 deletions src/WinRT.Runtime/Configuration/ILLink.Substitutions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
<!-- CSWINRT_USE_EXCEPTION_RESOURCE_KEYS switch -->
<method signature="System.Boolean get_UseExceptionResourceKeys()" body="stub" value="false" feature="CSWINRT_USE_EXCEPTION_RESOURCE_KEYS" featurevalue="false"/>
<method signature="System.Boolean get_UseExceptionResourceKeys()" body="stub" value="true" feature="CSWINRT_USE_EXCEPTION_RESOURCE_KEYS" featurevalue="true"/>

<!-- CSWINRT_ENABLE_DEFAULT_CUSTOM_TYPE_MAPPINGS switch -->
<method signature="System.Boolean get_EnableDefaultCustomTypeMappings()" body="stub" value="false" feature="CSWINRT_ENABLE_DEFAULT_CUSTOM_TYPE_MAPPINGS" featurevalue="false"/>
<method signature="System.Boolean get_EnableDefaultCustomTypeMappings()" body="stub" value="true" feature="CSWINRT_ENABLE_DEFAULT_CUSTOM_TYPE_MAPPINGS" featurevalue="true"/>
</type>
</assembly>

Expand Down
61 changes: 60 additions & 1 deletion src/WinRT.Runtime/MatchingRefApiCompatBaseline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,63 @@ MembersMustExist : Member 'public WinRT.ObjectReference<T> WinRT.ObjectReference
TypesMustExist : Type 'WinRT.ActivationFactory' does not exist in the reference but it does exist in the implementation.
CannotChangeAttribute : Attribute 'System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute' on 'ABI.System.Type.FromAbi(ABI.System.Type)' changed from '[UnconditionalSuppressMessageAttribute("ReflectionAnalysis", "IL2057", Justification="Any types which are trimmed are not used by managed user code and there is fallback logic to handle that.")]' in the implementation to '[UnconditionalSuppressMessageAttribute("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification="Any types which are trimmed are not used by managed user code and there is fallback logic to handle that.")]' in the reference.
CannotRemoveAttribute : Attribute 'System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute' exists on 'WinRT.MarshalDelegate.FromAbi<T>(System.IntPtr)' in the implementation but not the reference.
Total Issues: 140
MembersMustExist : Member 'public void WinRT.Projections.RegisterDataErrorsChangedEventArgsMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterDateTimeOffsetMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterEventHandlerMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterEventHandlerOpenGenericMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterEventRegistrationTokenMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterExceptionMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterIBindableVectorMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterICollectionMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterICollectionOpenGenericMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterICommandMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterIDictionaryOpenGenericMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterIDisposableMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterIEnumerableMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterIEnumerableOpenGenericMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterIEnumeratorOpenGenericMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterIListMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterIListOpenGenericMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterIMapOpenGenericMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterIMapViewOpenGenericMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterINotifyCollectionChangedMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterINotifyDataErrorInfoMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterINotifyPropertyChangedMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterIReadOnlyCollectionOpenGenericMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterIReadOnlyDictionaryOpenGenericMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterIReadOnlyListOpenGenericMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterIServiceProviderMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterIVectorOpenGenericMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterIVectorViewOpenGenericMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterKeyValuePairOpenGenericMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterMatrix3x2Mapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterMatrix4x4Mapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterNotifyCollectionChangedActionMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterNotifyCollectionChangedEventArgsMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterNotifyCollectionChangedEventHandlerMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterNullableBoolMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterNullableByteMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterNullableCharMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterNullableDateTimeOffsetMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterNullableDoubleMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterNullableFloatMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterNullableGuidMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterNullableIntMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterNullableLongMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterNullableOpenGenericMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterNullableSByteMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterNullableShortMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterNullableTimeSpanMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterNullableUIntMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterNullableULongMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterNullableUShortMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterPlaneMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterPropertyChangedEventArgsMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterPropertyChangedEventHandlerMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterQuaternionMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterTimeSpanMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterUriMapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterVector2Mapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterVector3Mapping()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.Projections.RegisterVector4Mapping()' does not exist in the reference but it does exist in the implementation.
Total Issues: 199
Loading
Loading