created a file to read and parse the assembly table#3
Conversation
|
|
||
|
|
||
| // return all parsed values | ||
| return { |
There was a problem hiding this comment.
Use parentheses instead of curly braces to define a tuple
| buildNumber, | ||
| revisionNumber, | ||
| flags, | ||
| publicKeyIndex, |
There was a problem hiding this comment.
You haven't parsed a value for this field
| // All of the metadata within the assembly table | ||
| let metadata: MetadataDB | ||
| let hashAlgId: AssemblyHashAlgorithm | ||
| let majorVersion UInt16 |
There was a problem hiding this comment.
Use a colon to separate the field name and type
| cultureIndex | ||
|
|
||
| ) = try metadata.withTableSpan(for: . assembly, rowIndex: rowIndex) // metadata is all the data that we'll be reading, withTableSpan, span is the range of bits we'll be parsing | ||
| { |
There was a problem hiding this comment.
Add span in after the curly brace opening the closure to receive the span argument
| struct Assembly { | ||
| // All of the metadata within the assembly table | ||
| let metadata: MetadataDB | ||
| let hashAlgId: AssemblyHashAlgorithm |
There was a problem hiding this comment.
Change this field name to hashAlgorithm since you will store the AssemblyHashAlgorithm type, not just the raw value
| @@ -0,0 +1,23 @@ | |||
| enum AssemblyHashAlgorithm: UInt32, Maskable { | |||
There was a problem hiding this comment.
You actually don't need the Maskable protocol for this one; the raw value only represents the assembly hash algorithm. If there were multiple pieces of information in the raw value, you would use the protocol to isolate the bits of interest for each one. The spec will also say what the mask is if there is one.
| case `sha1` = 0x8004 | ||
|
|
||
| // mask the raw value with the bit mask to get relevant bits | ||
| init?(masking rawValue: UInt32) { |
There was a problem hiding this comment.
You also don't need to write an initialiser because the compiler generates one that accepts your raw value type (UInt32)
| let typeNameIndex | ||
| let cultureIndex UInt32 | ||
| let publicKeyIndex: UInt32 | ||
| let typeNameIndex: UInt32 |
There was a problem hiding this comment.
This field comes from the TypeDef table and is not in the Assembly table
| struct AssemblyFlags: OptionSet { | ||
| let rawValue: UInt32 | ||
|
|
||
| static let PublicKey = 0x0001 |
There was a problem hiding this comment.
The convention in Swift is to start properties with a lowercase letter (camelCase)
No description provided.