Skip to content

Commit

Permalink
Improve layout of API docs. Fix typos.
Browse files Browse the repository at this point in the history
  • Loading branch information
Washi1337 committed May 13, 2023
1 parent 48aadf6 commit 2545e1a
Show file tree
Hide file tree
Showing 45 changed files with 272 additions and 184 deletions.
3 changes: 2 additions & 1 deletion docs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
/**/bin/
/**/obj/
_site/
api/
api/*/*.yml
api/*/*.manifest
4 changes: 4 additions & 0 deletions docs/api/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# AsmResolver API Reference

This is the full API reference of the AsmResolver project.

12 changes: 12 additions & 0 deletions docs/api/toc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
- name: AsmResolver.dll
href: core/toc.yml
- name: AsmResolver.PE.File.dll
href: pe-file/toc.yml
- name: AsmResolver.PE.dll
href: pe/toc.yml
- name: AsmResolver.PE.Win32Resources.dll
href: win32resources/toc.yml
- name: AsmResolver.DotNet.dll
href: dotnet/toc.yml
- name: AsmResolver.Symbols.Pdb.dll
href: symbols/toc.yml
8 changes: 0 additions & 8 deletions docs/articles/index.md

This file was deleted.

93 changes: 0 additions & 93 deletions docs/articles/toc.yml

This file was deleted.

103 changes: 94 additions & 9 deletions docs/docfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,112 @@
{
"src": [
{
"files": [
"**/*.csproj"
],
"files": [ "AsmResolver/*.csproj" ],
"src": "../src"
}
],
"dest": "api",
"dest": "api/core",
"includePrivateMembers": false,
"disableGitFeatures": false,
"disableDefaultFilter": false,
"noRestore": false,
"namespaceLayout": "flattened",
"memberLayout": "separatePages",
"memberLayout": "samePage",
"allowCompilationErrors": false
},
{
"src": [
{
"files": [ "AsmResolver.PE.File/*.csproj" ],
"src": "../src"
}
],
"dest": "api/pe-file",
"includePrivateMembers": false,
"disableGitFeatures": false,
"disableDefaultFilter": false,
"noRestore": false,
"namespaceLayout": "flattened",
"memberLayout": "samePage",
"allowCompilationErrors": false
},
{
"src": [
{
"files": [ "AsmResolver.PE/*.csproj" ],
"src": "../src"
}
],
"dest": "api/pe",
"includePrivateMembers": false,
"disableGitFeatures": false,
"disableDefaultFilter": false,
"noRestore": false,
"namespaceLayout": "flattened",
"memberLayout": "samePage",
"allowCompilationErrors": false
},
{
"src": [
{
"files": [ "AsmResolver.DotNet/*.csproj", "AsmResolver.DotNet.Dynamic/*.csproj" ],
"src": "../src"
}
],
"dest": "api/dotnet",
"includePrivateMembers": false,
"disableGitFeatures": false,
"disableDefaultFilter": false,
"noRestore": false,
"namespaceLayout": "flattened",
"memberLayout": "samePage",
"allowCompilationErrors": false
},
{
"src": [
{
"files": [ "AsmResolver.Symbols.Pdb/*.csproj" ],
"src": "../src"
}
],
"dest": "api/symbols",
"includePrivateMembers": false,
"disableGitFeatures": false,
"disableDefaultFilter": false,
"noRestore": false,
"namespaceLayout": "flattened",
"memberLayout": "samePage",
"allowCompilationErrors": false
},
{
"src": [
{
"files": [ "AsmResolver.PE.Win32Resources/*.csproj" ],
"src": "../src"
}
],
"dest": "api/win32resources",
"includePrivateMembers": false,
"disableGitFeatures": false,
"disableDefaultFilter": false,
"noRestore": false,
"namespaceLayout": "flattened",
"memberLayout": "samePage",
"allowCompilationErrors": false
}
],
"build": {
"content": [
{
"files": [
"api/**.yml",
"api/**/*.yml",
"api/index.md"
]
},
{
"files": [
"articles/**.md",
"articles/**/toc.yml",
"guides/**.md",
"guides/**/toc.yml",
"toc.yml",
"*.md"
]
Expand All @@ -51,7 +129,14 @@
"modern",
"my-template"
],
"postProcessors": [],
"postProcessors": [
"ExtractSearchIndex"
],
"globalMetadata": {
"_enableSearch": "true",
"_appTitle": "AsmResolver",
"_appName": "AsmResolver"
},
"keepFileLink": false,
"disableGitFeatures": false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ ISegment segment = ...
// Relocate a segment to an offsets-rva pair:
segment.UpdateOffsets(new RelocationParameters(offset: 0x200, rva: 0x2000);

Console.WriteLine("Offset: 0x{0:X8}", segment.Offset); // Prints 0x200
Console.WriteLine("Rva: 0x{0:X8}", segment.Rva); // Prints 0x2000
Console.WriteLine($"Offset: 0x{segment.Offset:X8}"); // Prints 0x200
Console.WriteLine($"Rva: 0x{segment.Rva:X8}"); // Prints 0x2000
```

> [!WARNING]
Expand All @@ -207,8 +207,8 @@ ISegment segment = ...
uint physicalSize = segment.GetPhysicalSize();
uint virtualSize = segment.GetVirtualSize();

Console.WriteLine("Physical (File) Size: 0x{0:X8}", physicalSize);
Console.WriteLine("Virtual (Runtime) Size: 0x{0:X8}", virtualSize);
Console.WriteLine($"Physical (File) Size: 0x{physicalSize:X8}");
Console.WriteLine($"Virtual (Runtime) Size: 0x{virtualSize:X8}");
```

> [!WARNING]
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ All references to methods defined in the
`System.Runtime.CompilerServices` namespace will then be mapped to the
appropriate method definitions if they exist in the target module.

See [Common Caveats using the Importer](/articles/dotnet/importing.html#common-caveats-using-the-importer)
See [Common Caveats using the Importer](/guides/dotnet/importing.html#common-caveats-using-the-importer)
for more information on reference importing and its caveats.

## Post-processing of cloned members
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@ contextModule.GetOrCreateModuleType().Methods.Add(definition);
contextModule.Write("Program.patched.dll");
```

See [Obtaining methods and fields](/articles/dotnet/member-tree.html#obtaining-methods-and-fields)
See [Obtaining methods and fields](/guides/dotnet/member-tree.html#obtaining-methods-and-fields)
and [CIL Method Bodies](managed-method-bodies.md) for more
information on how to use `MethodDefinition` objects.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,9 @@ includes the name, the type of the resource and the deserialized data:
``` csharp
foreach (var entry in set)
{
Console.WriteLine("Name: " + entry.Name);
Console.WriteLine("Type: " + entry.Type.FullName);
Console.WriteLine("Data: " + entry.Data);
Console.WriteLine($"Name: {entry.Name}");
Console.WriteLine($"Type: {entry.Type.FullName}");
Console.WriteLine($"Data: {entry.Data}");
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private static void DumpTypes(IEnumerable<TypeDefinition> types, int indentation
foreach (var type in types)
{
// Print the name of the current type.
Console.WriteLine("{0}- {1} : {2:X8}", indentation, type.Name, type.MetadataToken.ToInt32());
Console.WriteLine($"{indentation}- {type.Name} : {type.MetadataToken}");

// Dump any nested types.
DumpTypes(type.NestedTypes, indentationLevel + 1);
Expand All @@ -62,26 +62,26 @@ that the type defines:

``` csharp
foreach (var method in type.Methods)
Console.WriteLine("{0} : {1:X8}", method.Name, method.MetadataToken.ToInt32());
Console.WriteLine($"{method.Name} : {method.MetadataToken}");
```

``` csharp
foreach (var field in type.Fields)
Console.WriteLine("{0} : {1:X8}", field.Name, field.MetadataToken.ToInt32());
Console.WriteLine($"{field.Name} : {field.MetadataToken}");
```

Methods and fields have a `Signature` property, that contain the return
and parameter types, or the field type respectively.

``` csharp
MethodDefinition method = ...
Console.WriteLine("Return type: " + method.Signature.ReturnType);
Console.WriteLine("Parameter types: " + string.Join(", ", method.Signature.ParameterTypes));
Console.WriteLine($"Return type: {method.Signature.ReturnType}");
Console.WriteLine($"Parameter types: {string.Join(", ", method.Signature.ParameterTypes)}");
```

``` csharp
FieldDefinition field = ...
Console.WriteLine("Field type: " + field.Signature.FieldType);
Console.WriteLine($"Field type: {field.Signature.FieldType}");
```

However, for reading parameters from a method definition, it is
Expand All @@ -103,12 +103,12 @@ fields; `TypeDefinition` exposes them in a list as well:

``` csharp
foreach (var @event in type.Events)
Console.WriteLine("{0} : {1:X8}", @event.Name, @event.MetadataToken.ToInt32());
Console.WriteLine($"{@event.Name} : {@event.MetadataToken}");
```

``` csharp
foreach (var property in type.Properties)
Console.WriteLine("{0} : {1:X8}", property.Name, property.MetadataToken.ToInt32());
Console.WriteLine($"{property.Name} : {property.MetadataToken}");
```

Properties and events have methods associated to them. These are
Expand All @@ -117,7 +117,6 @@ accessible through the `Semantics` property:
``` csharp
foreach (MethodSemantics semantic in property.Semantics)
{
Console.WriteLine("{0} {1} : {2:X8}", semantic.Attributes, semantic.Method.Name,
semantic.MetadataToken.ToInt32());
Console.WriteLine($"{semantic.Attributes} {semantic.Method.Name} : {semantic.MetadataToken}");
}
```
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions docs/articles/faq.md → docs/guides/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ writing).

AsmResolver often can ignore and recover from kinds of errors, but this
is not enabled by default. To enable these, please refer to
[Advanced PE Image Reading](/articles/peimage/advanced-pe-reading.html#custom-error-handling) (PE)
or [Advanced Module Reading](/articles/dotnet/advanced-module-reading.html#pe-image-reading-parameters) (.NET),
and [Image Builder Diagnostics](/articles/dotnet/advanced-pe-image-building.html#image-builder-diagnostics) (.NET).
[Advanced PE Image Reading](/guides/peimage/advanced-pe-reading.html#custom-error-handling) (PE)
or [Advanced Module Reading](/guides/dotnet/advanced-module-reading.html#pe-image-reading-parameters) (.NET),
and [Image Builder Diagnostics](/guides/dotnet/advanced-pe-image-building.html#image-builder-diagnostics) (.NET).
Be careful with ignoring errors though. Especially for disabling writer
verification can cause the output to not work anymore unless you know
what you are doing.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 2545e1a

Please sign in to comment.