Skip to content

Commit

Permalink
Update docs for 2.6
Browse files Browse the repository at this point in the history
  • Loading branch information
MSDN-WhiteKnight committed Apr 2, 2023
1 parent 1f706fd commit 7960220
Show file tree
Hide file tree
Showing 92 changed files with 14,726 additions and 79 deletions.
7 changes: 7 additions & 0 deletions CilTools.BytecodeAnalysis/ReadMe.txt
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,10 @@ v2.0
- Fix `serializable` attribute handling
- Fix type name representation in syntax API (now namespace is handled as a separate identifier token)
- Fix detection of `<Module>` type (global fields and functions)

2.6
- Add new CilTools.Syntax.Tokens API for converting text into sequence of tokens
- Add support for .pack and .size directives
- Expose constant values as LiteralSyntax instead of GenericSyntax in Syntax API
- Update disassembler to not escape math symbols in string literals
- Fix CilInstruction.Parse to use invariant culture when parsing floating point values
8 changes: 8 additions & 0 deletions CilTools.Metadata/changes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# CilTools.Metadata changes

2.6

- Add support for getting inherited members in TypeDef and TypeRef. Now APIs like GetMembers return both declared and inherited members by default, and only declared ones when DeclaredOnly flag is specified.
- Implement Type.StructLayoutAttribute property on TypeDef
- Fix Type.IsValueType and Type.IsEnum returning incorrect values for .NET Core assemblies
- Fix token resolution to throw ArgumentOutOfRangeException instead of BadImageFormatException on out-of-range tokens
1 change: 1 addition & 0 deletions CilTools.SourceCode/CilTools.SourceCode.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net35</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageLicenseFile>license.txt</PackageLicenseFile>
<PackageIcon>IL.png</PackageIcon>
<PackageTags>dotnet dotnet-standard dotnet-framework code-analysis text-processing lexical-analysis tokens</PackageTags>
Expand Down
25 changes: 25 additions & 0 deletions CilTools.SourceCode/Common/SourceCodeUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

namespace CilTools.SourceCode.Common
{
/// <summary>
/// Provides static methods that assist in working with source code
/// </summary>
public static class SourceCodeUtils
{
static readonly SyntaxTokenDefinition[] s_vbDefinitions = new SyntaxTokenDefinition[] {
Expand Down Expand Up @@ -41,6 +44,10 @@ public static class SourceCodeUtils
static readonly SourceTokenFactory s_vbFactory = new SourceTokenFactory(
new VbClassifier(), SourceLanguage.VisualBasic);

/// <summary>
/// Gets a collection of token definitions that can be used to tokenize a source file with the specified extension
/// </summary>
/// <param name="ext">Source file extension with a leading dot (for example, <c>.cs</c> for C#)</param>
public static IEnumerable<SyntaxTokenDefinition> GetTokenDefinitions(string ext)
{
if (ext == null) ext = string.Empty;
Expand Down Expand Up @@ -69,6 +76,10 @@ static bool IsCppExtension(string ext)
return ext == ".cpp" || ext == ".c" || ext == ".h" || ext == string.Empty;
}

/// <summary>
/// Gets a syntax factory that creates tokens for the specified language (defined by source file extension)
/// </summary>
/// <param name="ext">Source file extension with a leading dot (for example, <c>.cs</c> for C#)</param>
public static SourceTokenFactory GetFactory(string ext)
{
if (ext == null) ext = string.Empty;
Expand All @@ -89,6 +100,9 @@ public static SourceTokenFactory GetFactory(string ext)
}
}

/// <summary>
/// Gets a syntax factory that creates tokens for the specified language
/// </summary>
public static SourceTokenFactory GetFactory(SourceLanguage lang)
{
switch (lang)
Expand All @@ -100,6 +114,17 @@ public static SourceTokenFactory GetFactory(SourceLanguage lang)
}
}

/// <summary>
/// Reads all tokens from the specified string using the specified collection of token definitions and syntax factory
/// </summary>
/// <param name="src">Input string</param>
/// <param name="definitions">
/// Collection of token definitions that will be used to split the input string into a sequence of tokens
/// </param>
/// <param name="factory">
/// Syntax factory object that will be used to create new <see cref="SyntaxNode"/> instances
/// </param>
/// <returns>Array of syntax nodes that contain tokens</returns>
public static SourceToken[] ReadAllTokens(string src, IEnumerable<SyntaxTokenDefinition> definitions,
SourceTokenFactory factory)
{
Expand Down
14 changes: 14 additions & 0 deletions CilTools.SourceCode/Common/SourceLanguage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,24 @@

namespace CilTools.SourceCode.Common
{
/// <summary>
/// Represents a programming language of the source code
/// </summary>
public enum SourceLanguage
{
/// <summary>
/// C#
/// </summary>
CSharp = 1,

/// <summary>
/// C++
/// </summary>
Cpp = 2,

/// <summary>
/// Visual Basic
/// </summary>
VisualBasic = 3
}
}
21 changes: 17 additions & 4 deletions CilTools.SourceCode/Common/SourceToken.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@
namespace CilTools.SourceCode.Common
{
/// <summary>
/// Represents a smallest lexical unit of a source text
/// (used for syntax highlighting in CIL View "Show source" feature)
/// Represents a smallest lexical unit of a source text
/// </summary>
public class SourceToken : SyntaxNode
public class SourceToken : SyntaxNode //used for syntax highlighting in CIL View "Show source" feature
{
TokenKind _kind;
string _content;

/// <summary>
/// Creates a new source token instance
/// </summary>
public SourceToken(string content, TokenKind kind)
{
this._kind = kind;
Expand All @@ -27,6 +29,9 @@ public SourceToken(string content, TokenKind kind)
this._trail = string.Empty;
}

/// <summary>
/// Creates a new source token instance with whitespace
/// </summary>
public SourceToken(string content, TokenKind kind, string leadingWhitespace, string trailingWhitespace)
{
this._kind = kind;
Expand All @@ -46,23 +51,31 @@ internal static SourceToken CreateFromString(string tokenString, string leadingW
return new SourceToken(tokenString, kind, leadingWhitespace, trailingWhitespace);
}

/// <summary>
/// Gets the token kind
/// </summary>
public TokenKind Kind
{
get { return this._kind; }
}

/// <summary>
/// Gets the text content of this token without leading and trailing whitespace
/// </summary>
public string Content
{
get { return this._content; }
}


/// <inheritdoc/>
public override void ToText(TextWriter target)
{
target.Write(this._lead);
target.Write(this._content);
target.Write(this._trail);
}

/// <inheritdoc/>
public override IEnumerable<SyntaxNode> EnumerateChildNodes()
{
return SyntaxNode.EmptyArray;
Expand Down
9 changes: 9 additions & 0 deletions CilTools.SourceCode/Common/SourceTokenFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

namespace CilTools.SourceCode.Common
{
/// <summary>
/// Provides a <see cref="SyntaxFactory"/> implementation that creates tokens for the specified source code language
/// </summary>
public class SourceTokenFactory : SyntaxFactory
{
TokenClassifier classifier;
Expand All @@ -20,11 +23,17 @@ internal SourceTokenFactory(TokenClassifier tc, SourceLanguage lang)
this.language = lang;
}

/// <summary>
/// Gets a programming language for this token factory
/// </summary>
public SourceLanguage Language
{
get { return this.language; }
}

/// <summary>
/// Creates a new source token
/// </summary>
public override SyntaxNode CreateNode(string content, string leadingWhitespace, string trailingWhitespace)
{
return SourceToken.CreateFromString(content, leadingWhitespace, trailingWhitespace, this.classifier);
Expand Down
8 changes: 8 additions & 0 deletions CilView/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,14 @@ Changelog

- Fix help when running from directory with non-latin characters in path

2.6

- Add support for .pack and .size directives
- Add support for C# verbatim strings in source viewer
- Use .NET Core runtime directory for .NET Standard 2.1 targeting assemblies when navigating to methods from BCL types
- Update disassembler to not escape math symbols in string literals
- Fix syntax highlighting for constant values

---------------------------------------------

Copyright (c) 2022, MSDN.WhiteKnight
Loading

0 comments on commit 7960220

Please sign in to comment.