Skip to content

Commit c1dfd1b

Browse files
committed
Fix trim warnings
1 parent df92923 commit c1dfd1b

File tree

6 files changed

+16
-9
lines changed

6 files changed

+16
-9
lines changed

src/Tools/dotnet-monitor/CollectionRules/Options/Actions/CollectLogsOptions.Validate.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ IEnumerable<ValidationResult> IValidatableObject.Validate(ValidationContext vali
2323
RequiredAttribute requiredAttribute = new();
2424
EnumDataTypeAttribute enumValidationAttribute = new(typeof(LogLevel));
2525

26-
ValidationContext filterSpecsContext = new(FilterSpecs, validationContext, validationContext.Items);
26+
ValidationContext filterSpecsContext = new(FilterSpecs, nameof(FilterSpecs), validationContext, validationContext.Items);
2727
filterSpecsContext.MemberName = nameof(FilterSpecs);
2828

2929
// Validate that the category is not null and that the level is a valid level value.

src/Tools/dotnet-monitor/CollectionRules/Options/Actions/CollectTraceOptions.Validate.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ IEnumerable<ValidationResult> IValidatableObject.Validate(ValidationContext vali
8888
int index = 0;
8989
foreach (EventPipeProvider provider in Providers)
9090
{
91-
ValidationContext providerContext = new(provider, validationContext, validationContext.Items);
91+
ValidationContext providerContext = new(provider, nameof(Providers), validationContext, validationContext.Items);
9292
providerContext.MemberName = nameof(Providers) + "[" + index.ToString(CultureInfo.InvariantCulture) + "]";
9393

9494
// Note: generated validation logic doesn't recurse into members of T for List<T>, when List<T> is not required.

src/Tools/dotnet-monitor/ConfigurationTokenParser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public ConfigurationTokenParser(ILogger logger)
6464
_logger = logger;
6565
}
6666

67-
public object? SubstituteOptionValues(object? originalSettings, Type settingsType, TokenContext context)
67+
public object? SubstituteOptionValues(object? originalSettings, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] Type settingsType, TokenContext context)
6868
{
6969
object? settings = originalSettings;
7070

src/Tools/dotnet-monitor/CustomValidationInfo.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ public CustomValidatablePropertyInfo(
193193
Name = name;
194194
}
195195

196+
[global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties | global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors)]
196197
internal Type ContainingType { get; }
197198
internal string Name { get; }
198199

@@ -202,10 +203,14 @@ protected override ValidationAttribute[] GetValidationAttributes()
202203

203204
static class ValidationAttributeCache
204205
{
205-
private sealed record CacheKey(Type ContainingType, string PropertyName);
206+
private sealed record CacheKey(
207+
[property: global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties | global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors)]
208+
Type ContainingType,
209+
string PropertyName);
206210
private static readonly ConcurrentDictionary<CacheKey, ValidationAttribute[]> _cache = new();
207211

208212
public static ValidationAttribute[] GetValidationAttributes(
213+
[param: global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties | global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors)]
209214
Type containingType,
210215
string propertyName)
211216
{
@@ -216,7 +221,7 @@ public static ValidationAttribute[] GetValidationAttributes(
216221

217222
// Get attributes from the property
218223
var property = k.ContainingType.GetProperty(k.PropertyName);
219-
if (property != null)
224+
if (property != null)
220225
{
221226
var propertyAttributes = CustomAttributeExtensions.GetCustomAttributes<ValidationAttribute>(property, inherit: true);
222227

src/Tools/dotnet-monitor/ServiceCollectionExtensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public static IServiceCollection ConfigureCollectionRules(this IServiceCollectio
197197
return services;
198198
}
199199

200-
public static IServiceCollection RegisterCollectionRuleAction<TFactory, TOptions, TDescriptor>(this IServiceCollection services)
200+
public static IServiceCollection RegisterCollectionRuleAction<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TFactory, TOptions, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TDescriptor>(this IServiceCollection services)
201201
where TFactory : class, ICollectionRuleActionFactory<TOptions>
202202
where TOptions : BaseRecordOptions, new()
203203
where TDescriptor : class, ICollectionRuleActionDescriptor
@@ -211,7 +211,7 @@ public static IServiceCollection RegisterCollectionRuleAction<TFactory, TOptions
211211
return services;
212212
}
213213

214-
public static IServiceCollection RegisterCollectionRuleTrigger<TFactory, TDescriptor>(this IServiceCollection services)
214+
public static IServiceCollection RegisterCollectionRuleTrigger<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TFactory, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TDescriptor>(this IServiceCollection services)
215215
where TFactory : class, ICollectionRuleTriggerFactory
216216
where TDescriptor : class, ICollectionRuleTriggerDescriptor
217217
{
@@ -221,7 +221,7 @@ public static IServiceCollection RegisterCollectionRuleTrigger<TFactory, TDescri
221221
return services;
222222
}
223223

224-
public static IServiceCollection RegisterCollectionRuleTrigger<TFactory, TOptions, TDescriptor>(this IServiceCollection services)
224+
public static IServiceCollection RegisterCollectionRuleTrigger<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TFactory, TOptions, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TDescriptor>(this IServiceCollection services)
225225
where TFactory : class, ICollectionRuleTriggerFactory<TOptions>
226226
where TOptions : class, new()
227227
where TDescriptor : class, ICollectionRuleTriggerDescriptor

src/Tools/dotnet-monitor/ValidatableInfoResolver.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1563,7 +1563,9 @@ internal static class GeneratedServiceCollectionExtensions
15631563
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.AspNetCore.Http.ValidationsGenerator, Version=10.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "10.0.0.0")]
15641564
file static class ValidationAttributeCache
15651565
{
1566-
private sealed record CacheKey([property: global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] global::System.Type ContainingType, string PropertyName);
1566+
private sealed record CacheKey(
1567+
[property: global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties| global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors)]
1568+
global::System.Type ContainingType, string PropertyName);
15671569
private static readonly global::System.Collections.Concurrent.ConcurrentDictionary<CacheKey, global::System.ComponentModel.DataAnnotations.ValidationAttribute[]> _cache = new();
15681570

15691571
public static global::System.ComponentModel.DataAnnotations.ValidationAttribute[] GetValidationAttributes(

0 commit comments

Comments
 (0)