Repository: MessagePack-CSharp/MessagePack-CSharp

Issue:
MsgPack004 Analyzer triggering on not attributed private property on base class eventhough source generator shouldn't include private properties
#### Bug description

When using non-partial classes forcing the source generator to only include public fields and removing the need to place attributes on non-public properties/fields, the MessagePackAnalyzer complains about not attributed private properties on the base class.

#### Repro steps
Create the following code:
```csharp
[MessagePackObject(AllowPrivate = false)]
public class A
{
    [Key(0)]
    public int SomePublicProp { get; set; }
    private int somePrivateProp { get; set; }
}

[MessagePackObject(AllowPrivate = false)]
public class B : A // Error is placed here
{
    [Key(1)]
    public int SomePublicProp2 { get; set; }
}
```
#### Expected behavior
The project should compile without issues.

#### Actual behavior
The compiler throws an error:
| Severity       | Code        | Description                                                       |
|----------------|-------------|-------------------------------------------------------------------|
| Error | MsgPack0004 | Properties and fields of base types of MessagePackObject-attributed types require either KeyAttribute or IgnoreMemberAttribute: global::A.somePrivateProp |

- Version used: 3.0.208-rc-0001
- Runtime: .NET 8

#### Additional context
The source generator seems to generate the intended formatter without issues
```csharp
// <auto-generated />

#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649

#pragma warning disable CS8669 // We may leak nullable annotations into generated code.

using MsgPack = global::MessagePack;

namespace MessagePack {
partial class GeneratedMessagePackResolver {

	internal sealed class BFormatter : MsgPack::Formatters.IMessagePackFormatter<global::B>
	{

		public void Serialize(ref MsgPack::MessagePackWriter writer, global::B value, MsgPack::MessagePackSerializerOptions options)
		{
			if (value == null)
			{
				writer.WriteNil();
				return;
			}

			writer.WriteArrayHeader(2);
			writer.Write(value.SomePublicProp);
			writer.Write(value.SomePublicProp2);
		}

		public global::B Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options)
		{
			if (reader.TryReadNil())
			{
				return null;
			}

			options.Security.DepthStep(ref reader);
			var length = reader.ReadArrayHeader();
			var ____result = new global::B();

			for (int i = 0; i < length; i++)
			{
				switch (i)
				{
					case 0:
						____result.SomePublicProp = reader.ReadInt32();
						break;
					case 1:
						____result.SomePublicProp2 = reader.ReadInt32();
						break;
					default:
						reader.Skip();
						break;
				}
			}

			reader.Depth--;
			return ____result;
		}
	}
}
}

```


Hints:

Patch:
diff --git a/src/MessagePack.SourceGenerator/CodeAnalysis/TypeCollector.cs b/src/MessagePack.SourceGenerator/CodeAnalysis/TypeCollector.cs
index 861720149..e077e5999 100644
--- a/src/MessagePack.SourceGenerator/CodeAnalysis/TypeCollector.cs
+++ b/src/MessagePack.SourceGenerator/CodeAnalysis/TypeCollector.cs
@@ -936,7 +936,14 @@ void ReportNonUniqueNameIfApplicable(ISymbol item, string stringKey)
                                             item.Name);
                                     if (reportedDiagnostics.Add(diagnostic))
                                     {
-                                        this.reportDiagnostic?.Invoke(diagnostic);
+                                        if (nonPublicMembersAreSerialized || (item.DeclaredAccessibility & Accessibility.Public) == Accessibility.Public)
+                                        {
+                                            this.reportDiagnostic?.Invoke(diagnostic);
+                                        }
+                                        else
+                                        {
+                                            deferredDiagnosticsForNonPublicMembers.Add(diagnostic);
+                                        }
                                     }
                                 }
                             }
@@ -1088,7 +1095,14 @@ void ReportNonUniqueNameIfApplicable(ISymbol item, string stringKey)
                                             item.Name);
                                     if (reportedDiagnostics.Add(diagnostic))
                                     {
-                                        this.reportDiagnostic?.Invoke(diagnostic);
+                                        if (nonPublicMembersAreSerialized || (item.DeclaredAccessibility & Accessibility.Public) == Accessibility.Public)
+                                        {
+                                            this.reportDiagnostic?.Invoke(diagnostic);
+                                        }
+                                        else
+                                        {
+                                            deferredDiagnosticsForNonPublicMembers.Add(diagnostic);
+                                        }
                                     }
                                 }
                             }


Test patch:
diff --git a/tests/MessagePack.SourceGenerator.Tests/MsgPack00xAnalyzerTests.cs b/tests/MessagePack.SourceGenerator.Tests/MsgPack00xAnalyzerTests.cs
index b35682b7a..3a421f7bf 100644
--- a/tests/MessagePack.SourceGenerator.Tests/MsgPack00xAnalyzerTests.cs
+++ b/tests/MessagePack.SourceGenerator.Tests/MsgPack00xAnalyzerTests.cs
@@ -878,6 +878,34 @@ public class B
         await VerifyCS.VerifyAnalyzerAsync(test);
     }
 
+    [Fact]
+    public async Task PrivateMembersInBaseClassNeedNoAttribution()
+    {
+        string test = /* lang=c#-test */ """
+            using MessagePack;
+
+            [MessagePackObject]
+            public class A
+            {
+                private int somePrivateField;
+
+                [Key(0)]
+                public int SomePublicProp { get; set; }
+
+                private int SomePrivateProp { get; set; }
+            }
+
+            [MessagePackObject]
+            public class B : A
+            {
+                [Key(1)]
+                public int SomePublicProp2 { get; set; }
+            }
+            """;
+
+        await VerifyCS.VerifyAnalyzerAsync(test);
+    }
+
     [Fact]
     public async Task NameCollisionsInForceMapMode()
     {
@@ -903,8 +931,7 @@ public class Derived : Base
 
                 public new string {|MsgPack018:TwoFaced|};
             }
-            """
-        ;
+            """;
 
         await VerifyCS.VerifyAnalyzerAsync(test);
     }