Skip to content

Commit 17faf1b

Browse files
authored
Merge pull request #6790 from sharwell/inline-array
Avoid reporting CA1823 for inline arrays
2 parents 2005d97 + 8c0be9d commit 17faf1b

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

src/Test.Utilities/AdditionalMetadataReferences.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information.
22

33
using System.Collections.Immutable;
4+
using System.IO;
45
using Microsoft.CodeAnalysis;
56
using Microsoft.CodeAnalysis.CSharp;
67
using Microsoft.CodeAnalysis.Testing;
@@ -9,6 +10,13 @@ namespace Test.Utilities
910
{
1011
public static class AdditionalMetadataReferences
1112
{
13+
public static ReferenceAssemblies Net80 { get; } = new ReferenceAssemblies(
14+
"net8.0",
15+
new PackageIdentity(
16+
"Microsoft.NETCore.App.Ref",
17+
"8.0.0-preview.6.23329.7"),
18+
Path.Combine("ref", "net8.0"));
19+
1220
public static ReferenceAssemblies Default { get; } = CreateDefaultReferenceAssemblies();
1321

1422
public static ReferenceAssemblies DefaultWithoutRoslynSymbols { get; } = ReferenceAssemblies.Default

src/Utilities/Compiler/Extensions/ISymbolExtensions.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ public static bool IsReadOnlyFieldOrProperty([NotNullWhen(returnValue: true)] th
626626
return symbol.GetAttributes(attributeType).FirstOrDefault();
627627
}
628628

629-
public static IEnumerable<AttributeData> GetAttributes(this ISymbol symbol, IEnumerable<INamedTypeSymbol> attributesToMatch)
629+
public static IEnumerable<AttributeData> GetAttributes(this ISymbol symbol, IEnumerable<INamedTypeSymbol?> attributesToMatch)
630630
{
631631
foreach (var attribute in symbol.GetAttributes())
632632
{
@@ -659,6 +659,20 @@ public static bool HasAnyAttribute(this ISymbol symbol, params INamedTypeSymbol?
659659
return symbol.GetAttributes(attributeTypesToMatch).Any();
660660
}
661661

662+
public static bool HasAnyAttribute(this ISymbol symbol, [NotNullWhen(true)] INamedTypeSymbol? attributeToMatch)
663+
{
664+
if (attributeToMatch is null)
665+
return false;
666+
667+
foreach (var attribute in symbol.GetAttributes())
668+
{
669+
if (SymbolEqualityComparer.Default.Equals(attribute.AttributeClass, attributeToMatch))
670+
return true;
671+
}
672+
673+
return false;
674+
}
675+
662676
/// <summary>
663677
/// Returns a value indicating whether the specified symbol has the specified
664678
/// attribute.

src/Utilities/Compiler/WellKnownTypeNames.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ internal static class WellKnownTypeNames
306306
public const string SystemRuntimeCompilerServicesConfiguredValueTaskAwaitable1 = "System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable`1";
307307
public const string SystemRuntimeCompilerServicesDisableRuntimeMarshallingAttribute = "System.Runtime.CompilerServices.DisableRuntimeMarshallingAttribute";
308308
public const string SystemRuntimeCompilerServicesICriticalNotifyCompletion = "System.Runtime.CompilerServices.ICriticalNotifyCompletion";
309+
public const string SystemRuntimeCompilerServicesInlineArrayAttribute = "System.Runtime.CompilerServices.InlineArrayAttribute";
309310
public const string SystemRuntimeCompilerServicesINotifyCompletion = "System.Runtime.CompilerServices.INotifyCompletion";
310311
public const string SystemRuntimeCompilerServicesInternalsVisibleToAttribute = "System.Runtime.CompilerServices.InternalsVisibleToAttribute";
311312
public const string SystemRuntimeCompilerServicesMethodImplOptions = "System.Runtime.CompilerServices.MethodImplOptions";

0 commit comments

Comments
 (0)