Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
return obj is ISpecificRecord &&
((obj as ISpecificRecord).Schema as RecordSchema).SchemaName.Equals((sc as RecordSchema).SchemaName);
case Schema.Type.Enumeration:
return obj.GetType().IsEnum && (sc as EnumSchema).Symbols.Contains(obj.ToString());
return obj.GetType().IsEnum && (sc as EnumSchema).Symbols.Contains(obj.ToString()) && sc.Name.Equals(obj.GetType().Name);

Check warning

Code scanning / CodeQL

Dereferenced variable may be null Warning

Variable
obj
may be null at this access as suggested by
this
null check.
Variable
obj
may be null at this access as suggested by
this
null check.
Copy link

Copilot AI Oct 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name comparison may fail for enums in namespaced schemas. The schema's Name property typically contains only the simple name, while obj.GetType().Name returns the C# type name. Consider using SchemaName.Equals() or Fullname for more robust matching, similar to how the Record case on line 140 uses SchemaName.Equals().

Suggested change
return obj.GetType().IsEnum && (sc as EnumSchema).Symbols.Contains(obj.ToString()) && sc.Name.Equals(obj.GetType().Name);
return obj.GetType().IsEnum
&& (sc as EnumSchema).Symbols.Contains(obj.ToString())
&& (sc as EnumSchema).SchemaName.Equals(obj.GetType());

Copilot uses AI. Check for mistakes.
case Schema.Type.Array:
return obj is System.Collections.IList;
case Schema.Type.Map:
Expand Down
2 changes: 1 addition & 1 deletion lang/csharp/src/apache/main/Specific/SpecificWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@
return obj is ISpecificRecord &&
((obj as ISpecificRecord).Schema as RecordSchema).SchemaName.Equals((sc as RecordSchema).SchemaName);
case Schema.Type.Enumeration:
return obj.GetType().IsEnum && (sc as EnumSchema).Symbols.Contains(obj.ToString());
return obj.GetType().IsEnum && (sc as EnumSchema).Symbols.Contains(obj.ToString()) && sc.Name.Equals(obj.GetType().Name);

Check warning

Code scanning / CodeQL

Dereferenced variable may be null Warning

Variable
obj
may be null at this access as suggested by
this
null check.
Variable
obj
may be null at this access as suggested by
this
null check.
Copy link

Copilot AI Oct 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name comparison may fail for enums in namespaced schemas. The schema's Name property typically contains only the simple name, while obj.GetType().Name returns the C# type name. Consider using SchemaName.Equals() or Fullname for more robust matching, similar to how the Record case on line 210 uses SchemaName.Equals().

Suggested change
return obj.GetType().IsEnum && (sc as EnumSchema).Symbols.Contains(obj.ToString()) && sc.Name.Equals(obj.GetType().Name);
return obj.GetType().IsEnum && (sc as EnumSchema).Symbols.Contains(obj.ToString()) &&
((sc as EnumSchema).SchemaName.Equals(obj.GetType().FullName));

Copilot uses AI. Check for mistakes.
case Schema.Type.Array:
return obj is System.Collections.IList;
case Schema.Type.Map:
Expand Down