Skip to content

Commit 118bb72

Browse files
authored
Code cleanup for src (#36565)
Part of #35884
1 parent 65a206f commit 118bb72

File tree

345 files changed

+10217
-9527
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

345 files changed

+10217
-9527
lines changed

src/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
<PackageReference Include="DotNetAnalyzers.DocumentationAnalyzers" PrivateAssets="All" />
1414
</ItemGroup>
1515

16-
</Project>
16+
</Project>

src/EFCore.Abstractions/ChangeTracking/Internal/ObservableBackedBindingList.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ namespace Microsoft.EntityFrameworkCore.ChangeTracking.Internal;
1414
/// doing so can result in application failures when updating to a new Entity Framework Core release.
1515
/// </summary>
1616
[RequiresUnreferencedCode(
17-
"BindingList raises ListChanged events with PropertyDescriptors. PropertyDescriptors require unreferenced code.")]
18-
[RequiresDynamicCode("Requires calling MakeGenericType on the property descriptor's type")]
17+
"BindingList raises ListChanged events with PropertyDescriptors. PropertyDescriptors require unreferenced code."),
18+
RequiresDynamicCode("Requires calling MakeGenericType on the property descriptor's type")]
1919
public class ObservableBackedBindingList<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] T> : SortableBindingList<T>
2020
{
2121
private bool _addingNewInstance;

src/EFCore.Abstractions/ChangeTracking/Internal/SortableBindingList.cs

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ namespace Microsoft.EntityFrameworkCore.ChangeTracking.Internal;
1313
/// any release. You should only use it directly in your code with extreme caution and knowing that
1414
/// doing so can result in application failures when updating to a new Entity Framework Core release.
1515
/// </summary>
16-
[RequiresUnreferencedCode("Raises ListChanged events with PropertyDescriptors. PropertyDescriptors require unreferenced code.")]
17-
[RequiresDynamicCode("Requires calling MakeGenericType on the property descriptor's type")]
16+
[RequiresUnreferencedCode("Raises ListChanged events with PropertyDescriptors. PropertyDescriptors require unreferenced code."),
17+
RequiresDynamicCode("Requires calling MakeGenericType on the property descriptor's type")]
1818
public class SortableBindingList<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] T> : BindingList<T>
1919
{
2020
private bool _isSorted;
@@ -39,18 +39,16 @@ public SortableBindingList(List<T> list)
3939
/// any release. You should only use it directly in your code with extreme caution and knowing that
4040
/// doing so can result in application failures when updating to a new Entity Framework Core release.
4141
/// </summary>
42-
[RequiresUnreferencedCode("Requires accessing property 'Default' on the property descriptor's type")]
43-
[RequiresDynamicCode("Requires calling MakeGenericType on the property descriptor's type")]
44-
[UnconditionalSuppressMessage(
45-
"ReflectionAnalysis",
46-
"IL2046",
47-
Justification =
48-
"This method is an override, and the base method isn't annotated with RequiresUnreferencedCode. "
49-
+ "The entire type is marked with RequiresUnreferencedCode.")]
50-
[SuppressMessage(
51-
"AOT", "IL3051:'RequiresDynamicCodeAttribute' annotations must match across all interface implementations or overrides.",
52-
Justification = "This method is an override, and the base method isn't annotated with RequiresDynamicCode. "
53-
+ "The entire type is marked with RequiresDynamicCode.")]
42+
[RequiresUnreferencedCode("Requires accessing property 'Default' on the property descriptor's type"),
43+
RequiresDynamicCode("Requires calling MakeGenericType on the property descriptor's type"), UnconditionalSuppressMessage(
44+
"ReflectionAnalysis",
45+
"IL2046",
46+
Justification =
47+
"This method is an override, and the base method isn't annotated with RequiresUnreferencedCode. "
48+
+ "The entire type is marked with RequiresUnreferencedCode."), SuppressMessage(
49+
"AOT", "IL3051:'RequiresDynamicCodeAttribute' annotations must match across all interface implementations or overrides.",
50+
Justification = "This method is an override, and the base method isn't annotated with RequiresDynamicCode. "
51+
+ "The entire type is marked with RequiresDynamicCode.")]
5452
protected override void ApplySortCore(PropertyDescriptor prop, ListSortDirection direction)
5553
{
5654
if (PropertyComparer.CanSort(prop.PropertyType))
@@ -117,8 +115,8 @@ private sealed class PropertyComparer : Comparer<T>
117115
private readonly ListSortDirection _direction;
118116
private readonly PropertyDescriptor _prop;
119117

120-
[RequiresUnreferencedCode("Requires accessing property 'Default' on the property descriptor's type")]
121-
[RequiresDynamicCode("Requires calling MakeGenericType on the property descriptor's type")]
118+
[RequiresUnreferencedCode("Requires accessing property 'Default' on the property descriptor's type"),
119+
RequiresDynamicCode("Requires calling MakeGenericType on the property descriptor's type")]
122120
public PropertyComparer(PropertyDescriptor prop, ListSortDirection direction)
123121
{
124122
if (!prop.ComponentType.IsAssignableFrom(typeof(T)))

src/EFCore.Abstractions/ChangeTracking/ObservableCollectionListSource.cs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,16 @@ bool IListSource.ContainsListCollection
7575
/// An <see cref="IBindingList" /> in sync with the ObservableCollection.
7676
/// </returns>
7777
[RequiresUnreferencedCode(
78-
"BindingList raises ListChanged events with PropertyDescriptors. PropertyDescriptors require unreferenced code.")]
79-
[RequiresDynamicCode("Requires calling MakeGenericType on the property descriptor's type")]
80-
[UnconditionalSuppressMessage(
81-
"ReflectionAnalysis",
82-
"IL2046",
83-
Justification =
84-
"This method is an interface implementation, and the interface method isn't annotated with RequiresUnreferencedCode. "
85-
+ "The entire type is marked with RequiresUnreferencedCode.")]
86-
[SuppressMessage(
87-
"AOT", "IL3051:'RequiresDynamicCodeAttribute' annotations must match across all interface implementations or overrides.",
88-
Justification = "This method is an override, and the base method isn't annotated with RequiresDynamicCode. "
89-
+ "The entire type is marked with RequiresDynamicCode.")]
78+
"BindingList raises ListChanged events with PropertyDescriptors. PropertyDescriptors require unreferenced code."),
79+
RequiresDynamicCode("Requires calling MakeGenericType on the property descriptor's type"), UnconditionalSuppressMessage(
80+
"ReflectionAnalysis",
81+
"IL2046",
82+
Justification =
83+
"This method is an interface implementation, and the interface method isn't annotated with RequiresUnreferencedCode. "
84+
+ "The entire type is marked with RequiresUnreferencedCode."), SuppressMessage(
85+
"AOT", "IL3051:'RequiresDynamicCodeAttribute' annotations must match across all interface implementations or overrides.",
86+
Justification = "This method is an override, and the base method isn't annotated with RequiresDynamicCode. "
87+
+ "The entire type is marked with RequiresDynamicCode.")]
9088
IList IListSource.GetList()
9189
=> _bindingList ??= this.ToBindingList();
9290
}

src/EFCore.Abstractions/EntityTypeConfigurationAttribute.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ public class EntityTypeConfigurationAttribute : Attribute
1919
/// Initializes a new instance of the <see cref="EntityTypeConfigurationAttribute" /> class.
2020
/// </summary>
2121
/// <param name="entityConfigurationType">The IEntityTypeConfiguration&lt;&gt; type to use.</param>
22-
public EntityTypeConfigurationAttribute([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | DynamicallyAccessedMemberTypes.Interfaces)] Type entityConfigurationType)
22+
public EntityTypeConfigurationAttribute(
23+
[DynamicallyAccessedMembers(
24+
DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | DynamicallyAccessedMemberTypes.Interfaces)]
25+
Type entityConfigurationType)
2326
{
2427
Check.NotNull(entityConfigurationType);
2528

src/EFCore.Abstractions/ObservableCollectionExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ public static class ObservableCollectionExtensions
2525
/// <param name="source">The collection that the binding list will stay in sync with.</param>
2626
/// <returns>The binding list.</returns>
2727
[RequiresUnreferencedCode(
28-
"BindingList raises ListChanged events with PropertyDescriptors. PropertyDescriptors require unreferenced code.")]
29-
[RequiresDynamicCode("Requires calling MakeGenericType on the property descriptor's type")]
28+
"BindingList raises ListChanged events with PropertyDescriptors. PropertyDescriptors require unreferenced code."),
29+
RequiresDynamicCode("Requires calling MakeGenericType on the property descriptor's type")]
3030
public static BindingList<T> ToBindingList<T>(this ObservableCollection<T> source)
3131
where T : class
3232
=> new ObservableBackedBindingList<T>(source);

src/EFCore.Analyzers/EFCore.Analyzers.nuspec

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2+
23
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
34
<metadata>
45
$CommonMetadataElements$
@@ -14,4 +15,4 @@
1415
<file src="$OutputBinary$" target="analyzers\dotnet\cs\" />
1516
<file src="$OutputSymbol$" target="analyzers\dotnet\cs\" />
1617
</files>
17-
</package>
18+
</package>

src/EFCore.Analyzers/InternalUsageDiagnosticAnalyzer.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ private static readonly DiagnosticDescriptor Descriptor
2323
defaultSeverity: DiagnosticSeverity.Warning,
2424
isEnabledByDefault: true);
2525

26-
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics => [Descriptor];
26+
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics
27+
=> [Descriptor];
2728

2829
public override void Initialize(AnalysisContext context)
2930
{
@@ -308,14 +309,13 @@ private static bool IsInternal(OperationAnalysisContext context, ITypeSymbol sym
308309
&& (IsInInternalNamespace(symbol) || HasInternalAttribute(symbol));
309310

310311
private static bool HasInternalAttribute(ISymbol symbol)
311-
=> symbol.GetAttributes().Any(
312-
a =>
313-
a.AttributeClass!.ToDisplayString()
314-
== "Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkInternalAttribute");
312+
=> symbol.GetAttributes().Any(a =>
313+
a.AttributeClass!.ToDisplayString()
314+
== "Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkInternalAttribute");
315315

316316
private static bool IsInInternalNamespace(ISymbol symbol)
317317
{
318-
if (symbol?.ContainingNamespace?.ToDisplayString() is string ns)
318+
if (symbol?.ContainingNamespace?.ToDisplayString() is { } ns)
319319
{
320320
var i = ns.IndexOf("EntityFrameworkCore", StringComparison.Ordinal);
321321

src/EFCore.Analyzers/InterpolatedStringUsageInRawQueriesCodeFixProvider.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111

1212
namespace Microsoft.EntityFrameworkCore;
1313

14-
[ExportCodeFixProvider(LanguageNames.CSharp, Name = nameof(InterpolatedStringUsageInRawQueriesCodeFixProvider))]
15-
[Shared]
14+
[ExportCodeFixProvider(LanguageNames.CSharp, Name = nameof(InterpolatedStringUsageInRawQueriesCodeFixProvider)), Shared]
1615
public sealed class InterpolatedStringUsageInRawQueriesCodeFixProvider : CodeFixProvider
1716
{
18-
public override ImmutableArray<string> FixableDiagnosticIds => [EFDiagnostics.InterpolatedStringUsageInRawQueries];
17+
public override ImmutableArray<string> FixableDiagnosticIds
18+
=> [EFDiagnostics.InterpolatedStringUsageInRawQueries];
1919

2020
public override FixAllProvider GetFixAllProvider()
2121
=> WellKnownFixAllProviders.BatchFixer;

src/EFCore.Analyzers/InterpolatedStringUsageInRawQueriesDiagnosticAnalyzer.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ private static readonly DiagnosticDescriptor Descriptor
2121
defaultSeverity: DiagnosticSeverity.Warning,
2222
isEnabledByDefault: true);
2323

24-
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics => [Descriptor];
24+
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics
25+
=> [Descriptor];
2526

2627
public override void Initialize(AnalysisContext context)
2728
{

0 commit comments

Comments
 (0)