[Serializable] attribute over a class makes it considered like a Unity [SerializeField] by InspectCode

I run the following code through InspectCode.exe:
```

using System;
using UnityEngine;

[Serializable]
public class Foo
{
    public int FooVar;
}

public class Bar : MonoBehaviour
{
    [SerializeField] private int BarVar;
}
```


I have a rule defined for Unity Serialized Fields, to have a naming scheme like `_lowerCase`:
 I get a warning for BarVar as expected, but also one for FoorVar !

```
          "ruleId": "InconsistentNaming",
         "ruleIndex": 0,
         "level": "warning",
         "message": {
           "text": "Name 'BarVar' does not match rule 'Unity serialized field'. Suggested name is '_barVar'."
         },
         "locations": [  
           {
            ….
         ],
         "properties": {
           "tags": ["C#",".NETFramework 4.7.1"]
         }
       },
       {
         "ruleId": "InconsistentNaming",
         "ruleIndex": 0,
         "level": "warning",
         "message": {
           "text": "Name 'FooVar' does not match rule 'Unity serialized field'. Suggested name is '_fooVar'."
         },
         "locations": [
           …
         "properties": {
           "tags": ["C#",".NETFramework 4.7.1"]
         }
       },
```

Why is that? Is something running behind the scenes without my permission?

0

Please sign in to leave a comment.