Skip to content

created a file to read and parse the assembly table#3

Open
vromanuel wants to merge 2 commits into
TwirlySeal:mainfrom
vromanuel:manny-branch
Open

created a file to read and parse the assembly table#3
vromanuel wants to merge 2 commits into
TwirlySeal:mainfrom
vromanuel:manny-branch

Conversation

@vromanuel
Copy link
Copy Markdown

No description provided.

Comment thread Sources/Generator/Tables/Assembly.swift Outdated


// return all parsed values
return {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Use parentheses instead of curly braces to define a tuple

buildNumber,
revisionNumber,
flags,
publicKeyIndex,
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

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
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Use a colon to separate the field name and type

Comment thread Sources/Generator/Tables/Assembly.swift Outdated
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
{
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Add span in after the curly brace opening the closure to receive the span argument

Comment thread Sources/Generator/Tables/Assembly.swift Outdated
struct Assembly {
// All of the metadata within the assembly table
let metadata: MetadataDB
let hashAlgId: AssemblyHashAlgorithm
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

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 {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

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) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

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
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This field comes from the TypeDef table and is not in the Assembly table

struct AssemblyFlags: OptionSet {
let rawValue: UInt32

static let PublicKey = 0x0001
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

The convention in Swift is to start properties with a lowercase letter (camelCase)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants