Skip to content

Commit

Permalink
fix: issues while parsing array type definitions in dotnet module.
Browse files Browse the repository at this point in the history
  • Loading branch information
plusvic committed May 2, 2024
1 parent dc49fcc commit f26df27
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 10 deletions.
27 changes: 18 additions & 9 deletions lib/src/modules/dotnet/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1212,19 +1212,28 @@ impl<'a> Dotnet<'a> {

write!(output, "[")?;
for i in 0..dimensions {
let size = sizes.get(i as usize).cloned().unwrap_or(0);
if size > 0 {
let l =
lower_bounds.get(i as usize).cloned().unwrap_or(0);
let h = l + (size as i32);
if l == 0 {
let i = i as usize;
let size = sizes.get(i).cloned().map(|s| s as i32);
let lower_bound = lower_bounds.get(i).cloned();

match (lower_bound, size) {
(Some(0), Some(size)) => {
write!(output, "{}", size)?;
} else {
write!(output, "{}...{}", l, h)?;
}
(Some(l), Some(size)) if size >= 1 => {
write!(output, "{}...{}", l, l + size - 1)?;
}
(Some(l), None) => {
write!(output, "{}...", l)?;
}
(None, Some(size)) => {
write!(output, "{}", size)?;
}
_ => {}
}

// If not the last item, prepend a comma.
if i + 1 != dimensions {
if i + 1 != dimensions as usize {
write!(output, ",")?;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6402,7 +6402,7 @@ classes:
- name: "stomizeService"
type: "dLine.Definitions.solverDef<erSerializer.estComparator,object[]>"
- name: "eField"
type: "erSerializer.Prototype<ototypeAuth,erSerializer.estComparator>[668,-55...-53,-64...-46,-55...54,1...30,7...35,-61...-54,1...11,-54...-52,9...27,534...1594,-63...-45,-55...54,11,-55...-34,-64...-46,-55...1013,1...4,,,]"
type: "erSerializer.Prototype<ototypeAuth,erSerializer.estComparator>[668,-55...-54,-64...-47,-55...53,1...29,7...34,-61...-55,1...10,-54...-53,9...26,534...1593,-63...-46,-55...53,11,-55...-35,-64...-47,-55...1012,1...3,4...,,]"
- name: "wField"
type: "byte"
- name: "lComparator"
Expand Down
Binary file not shown.
112 changes: 112 additions & 0 deletions lib/src/modules/dotnet/tests/testdata/types2.dll.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
is_dotnet: true
module_name: "types2.dll"
version: "v4.0.30319"
number_of_streams: 5
number_of_guids: 1
number_of_resources: 0
number_of_classes: 2
number_of_assembly_refs: 0
number_of_modulerefs: 0
number_of_user_strings: 1
number_of_constants: 0
number_of_field_offsets: 0
streams:
- name: "#~"
offset: 708
size: 216
- name: "#Strings"
offset: 924
size: 100
- name: "#US"
offset: 1024
size: 8
- name: "#GUID"
offset: 1032
size: 16
- name: "#Blob"
offset: 1048
size: 172
guids:
- "de63c758-8c65-4928-b244-b60ad6cdb2a0"
classes:
- fullname: "Cmk"
name: "Cmk"
visibility: "public"
type: "class"
abstract: false
sealed: false
number_of_base_types: 1
number_of_generic_parameters: 0
number_of_methods: 0
base_types:
- "<Module>"
- fullname: "VolatileMethods"
name: "VolatileMethods"
visibility: "public"
type: "class"
abstract: false
sealed: false
number_of_base_types: 1
number_of_generic_parameters: 0
number_of_methods: 3
base_types:
- "<Module>"
methods:
- name: "withCmod"
visibility: "public"
abstract: false
static: false
virtual: false
final: false
return_type: "void"
number_of_generic_parameters: 0
number_of_parameters: 2
parameters:
- name: "i"
type: "Ptr<int>"
- name: "j"
type: "int"
- name: "withArrays"
visibility: "public"
abstract: false
static: false
virtual: false
final: false
return_type: "void"
number_of_generic_parameters: 0
number_of_parameters: 7
parameters:
- name: "a"
type: "int[3]"
- name: "b"
type: "uint[4,1...2,0,,,]"
- name: "c"
type: "short[1...2,6...8]"
- name: "d"
type: "ulong[5,3...5,,]"
- name: "e"
type: "byte[8...23,0,5,2...2,-5...8,3...4]"
- name: "f"
type: "sbyte[53...,-34...]"
- name: "g"
type: "ushort[1032...8388608,-1032...512,-8388608...-1032]"
- name: "compressionValues"
visibility: "public"
abstract: false
static: false
virtual: false
final: false
return_type: "void"
number_of_generic_parameters: 0
number_of_parameters: 4
parameters:
- name: "a"
type: "sbyte[-65...,-64...,63...,64...]"
- name: "b"
type: "sbyte[-8193...,-8192...,8191...,8192...]"
- name: "c"
type: "sbyte[-268435456...,268435455...]"
- name: "d"
type: "sbyte[0,127,128,256,16383,16384,268435455]"
user_strings:
- " \x00"

0 comments on commit f26df27

Please sign in to comment.