Skip to content

Update DataProtectionKey to use DynamicDependency #43207

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

Merged
merged 2 commits into from
Aug 11, 2022
Merged
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
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics.CodeAnalysis;

namespace Microsoft.AspNetCore.DataProtection.EntityFrameworkCore;

/// <summary>
/// Code first model used by <see cref="EntityFrameworkCoreXmlRepository{TContext}"/>.
/// </summary>
// DataProtectionKey.Id is not used anywhere. Add DynamicallyAccessedMembers to prevent it from being trimmed.
// Note that in the future EF may annotate itself to include properties automatically, and the annotation here could be removed.
// Fixes https://github.com/dotnet/aspnetcore/issues/43187
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)]
public class DataProtectionKey
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Xml.Linq;
using Microsoft.AspNetCore.DataProtection.Repositories;
Expand All @@ -24,6 +25,10 @@ public class EntityFrameworkCoreXmlRepository<TContext> : IXmlRepository
/// </summary>
/// <param name="services"></param>
/// <param name="loggerFactory">The <see cref="ILoggerFactory"/>.</param>
// DataProtectionKey.Id is not used anywhere. Add DynamicDependency to prevent it from being trimmed.
// Note that in the future EF may annotate itself to include properties automatically, and the annotation here could be removed.
// Fixes https://github.com/dotnet/aspnetcore/issues/43187
[DynamicDependency(DynamicallyAccessedMemberTypes.PublicProperties, typeof(DataProtectionKey))]
public EntityFrameworkCoreXmlRepository(IServiceProvider services, ILoggerFactory loggerFactory)
{
if (loggerFactory == null)
Expand Down