Skip to content
Merged
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
7 changes: 6 additions & 1 deletion src/CustomCode-Analyzer/Analyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1408,9 +1408,14 @@ private static bool HasIncompatibleDataTypeMapping(ITypeSymbol type, TypedConsta
return true;
}

// If the type is an array, reconstruct the expected type name ("Byte[]" from type "Byte")
string actualTypeName = type is IArrayTypeSymbol arrayType
? arrayType.ElementType.Name + "[]"
: type.Name;

// Finally, compare the actual .NET type name with the expected
// .NET type name from TypeMappingHelper
return !type.Name.Equals(expectedDotNetType, StringComparison.OrdinalIgnoreCase);
return !actualTypeName.Equals(expectedDotNetType, StringComparison.OrdinalIgnoreCase);
}
}
}
18 changes: 18 additions & 0 deletions tests/CustomCode-Analyzer.Tests/AnalyzerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1318,6 +1318,24 @@ await CSharpAnalyzerVerifier<Analyzer>.VerifyAnalyzerAsync(
);
}

[TestMethod]
public async Task UnsupportedTypeMappingRule_ArrayOfBytes_NoDiagnostic()
{
var source =
@"
[OSStructure]
public struct TestStruct
{
[OSStructureField(DataType = OSDataType.BinaryData)]
public byte[] RawBytes;
}";
await CSharpAnalyzerVerifier<Analyzer>.VerifyAnalyzerAsync(
source,
TestContext,
skipSDKreference: false
);
}

// --------------- MissingPublicImplementationRule (OS-ELG-MODL-05018) --------
[TestMethod]
public async Task MissingPublicImplementationRule_InGlobalScope_ReportsWarning()
Expand Down