From dd70714ab040959812909e85570c49c09ba0e45c Mon Sep 17 00:00:00 2001 From: Josef Pihrt Date: Wed, 6 Mar 2024 16:00:30 +0100 Subject: [PATCH] Fix UnityEngine.SerializeField name (#1419) --- ChangeLog.md | 1 + .../Analysis/MakeMemberReadOnly/MakeMemberReadOnlyAnalyzer.cs | 4 ++-- src/Tests/Analyzers.Tests/RCS1169MakeFieldReadOnlyTests.cs | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index d8650ee6b0..5aed4baa7b 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fix analyzer [RCS1267](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1267) ([PR](https://github.com/dotnet/roslynator/pull/1412)) - Fix "Unknown value 'Default'" exception ([PR](https://github.com/dotnet/roslynator/pull/1411)) +- Fix name of `UnityEngine.SerializeField` attribute ([PR](https://github.com/dotnet/roslynator/pull/1419)) ## [4.11.0] - 2024-02-19 diff --git a/src/Analyzers/CSharp/Analysis/MakeMemberReadOnly/MakeMemberReadOnlyAnalyzer.cs b/src/Analyzers/CSharp/Analysis/MakeMemberReadOnly/MakeMemberReadOnlyAnalyzer.cs index ab11ee869a..49665c5c9e 100644 --- a/src/Analyzers/CSharp/Analysis/MakeMemberReadOnly/MakeMemberReadOnlyAnalyzer.cs +++ b/src/Analyzers/CSharp/Analysis/MakeMemberReadOnly/MakeMemberReadOnlyAnalyzer.cs @@ -18,7 +18,7 @@ public sealed class MakeMemberReadOnlyAnalyzer : BaseDiagnosticAnalyzer private static readonly MetadataName Microsoft_AspNetCore_Components_CascadingParameterAttribute = MetadataName.Parse("Microsoft.AspNetCore.Components.CascadingParameterAttribute"); private static readonly MetadataName Microsoft_AspNetCore_Components_InjectAttribute = MetadataName.Parse("Microsoft.AspNetCore.Components.InjectAttribute"); private static readonly MetadataName Newtonsoft_Json_JsonPropertyAttribute = MetadataName.Parse("Newtonsoft.Json.JsonPropertyAttribute"); - private static readonly MetadataName UnityEngine_SerializeFieldAttribute = MetadataName.Parse("UnityEngine.SerializeFieldAttribute"); + private static readonly MetadataName UnityEngine_SerializeField = MetadataName.Parse("UnityEngine.SerializeField"); private static ImmutableArray _supportedDiagnostics; @@ -140,7 +140,7 @@ private static void AnalyzeTypeDeclaration(SyntaxNodeAnalysisContext context) && !fieldSymbol.IsVolatile && ValidateType(fieldSymbol.Type) && (context.IsUnityCodeAnalysisEnabled() != true - || !fieldSymbol.HasAttribute(UnityEngine_SerializeFieldAttribute))) + || !fieldSymbol.HasAttribute(UnityEngine_SerializeField))) { symbols[fieldSymbol.Name] = (declarator, fieldSymbol); } diff --git a/src/Tests/Analyzers.Tests/RCS1169MakeFieldReadOnlyTests.cs b/src/Tests/Analyzers.Tests/RCS1169MakeFieldReadOnlyTests.cs index b0da020306..6491331e86 100644 --- a/src/Tests/Analyzers.Tests/RCS1169MakeFieldReadOnlyTests.cs +++ b/src/Tests/Analyzers.Tests/RCS1169MakeFieldReadOnlyTests.cs @@ -393,7 +393,7 @@ class C namespace UnityEngine { - class SerializeFieldAttribute : Attribute + class SerializeField : Attribute { } }