Enabled Nullable reference types. Added a temporary fix for clonable NRT warnings.

This commit is contained in:
Kwoth
2021-12-28 10:40:59 +01:00
parent 89c2cda9ec
commit 0634470a8a
6 changed files with 320 additions and 6 deletions

View File

@@ -0,0 +1,26 @@
// Code temporarily yeeted from
// https://github.com/mostmand/Cloneable/blob/master/Cloneable/CloneableGenerator.cs
// because of NRT issue
using System.Collections.Generic;
using System.Linq;
using Microsoft.CodeAnalysis;
namespace Cloneable
{
internal static class SymbolExtensions
{
public static bool TryGetAttribute(this ISymbol symbol, INamedTypeSymbol attributeType,
out IEnumerable<AttributeData> attributes)
{
attributes = symbol.GetAttributes()
.Where(a => SymbolEqualityComparer.Default.Equals(a.AttributeClass, attributeType));
return attributes.Any();
}
public static bool HasAttribute(this ISymbol symbol, INamedTypeSymbol attributeType)
{
return symbol.GetAttributes()
.Any(a => SymbolEqualityComparer.Default.Equals(a.AttributeClass, attributeType));
}
}
}