Skip to content
Draft
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
1846335
Initial start on managed ilasm
jkoritzinsky Nov 19, 2022
a28f090
Add grammar in ANTLR4 format so we can get started.
jkoritzinsky Nov 23, 2022
a932050
Start implementing the visitor that goes from a parse tree to a usefu…
jkoritzinsky Nov 24, 2022
8b90478
Implement most of serInit parsing/serialization.
jkoritzinsky Nov 29, 2022
342f944
Add parsing for class declaration info as well as some other related …
jkoritzinsky Dec 3, 2022
ce8753d
Implement looking up typeRefs and most of the support for typeSpecs
jkoritzinsky Dec 10, 2022
d560635
Implement signature parsing and the start of method parsing and the p…
jkoritzinsky Dec 20, 2022
d950d48
Start work on method bodies and refactor flags handling to be more un…
jkoritzinsky Dec 21, 2022
9a3861a
Implement instruction and exception handling emit. Start marking meth…
jkoritzinsky Dec 28, 2022
616fc4f
Implement all non-debugging branches of methodDecl
jkoritzinsky Dec 30, 2022
c97a514
Implement property and event parsing and clean up grammar
jkoritzinsky Dec 31, 2022
4bb3db9
Add TODOs for the unimplemented nodes
jkoritzinsky Dec 31, 2022
fb4f372
Get build passing in VS
jkoritzinsky Dec 28, 2023
83d1884
Implement more cases
jkoritzinsky Dec 28, 2023
809c33f
Implement manifest resources.
jkoritzinsky Dec 29, 2023
32c4e0e
Set method entrypoint
jkoritzinsky Dec 29, 2023
508e1aa
Move a little code around
jkoritzinsky Dec 29, 2023
874e98f
Finish up exported types and start on emitting
jkoritzinsky Dec 30, 2023
48971f6
Add token resolution and add the first few tables of writing out into…
jkoritzinsky Dec 30, 2023
e6ed4d9
Handle Param and InterfaceImpl tables
jkoritzinsky Dec 30, 2023
7aafa5c
Write out the rest of the easy tables.
jkoritzinsky Jan 2, 2024
b9ca5f9
Implement MethodSpec parsing correctly, resolve MemberRefs to MethodD…
jkoritzinsky Jan 2, 2024
6cc9396
Finish up DocumentParser.Parse so we can start testing basic scenarios.
jkoritzinsky Jan 4, 2024
a21e185
Depend on an LKG SRM instead of a live one. Write the first (still fa…
jkoritzinsky Jan 5, 2024
ba1b2e8
Get the first compilation test passing!
jkoritzinsky Jan 5, 2024
d7bd8a3
Merge branch 'main' of https://github.com/dotnet/runtime into ilasm
jkoritzinsky Dec 2, 2025
b2ffc81
Hook up build infra
jkoritzinsky Dec 2, 2025
df76130
Upgrade ilasm to NetCoreAppToolCurrent
jkoritzinsky Dec 2, 2025
1a05564
No stage dependencies for managed ilasm
jkoritzinsky Dec 2, 2025
f128815
Apply suggestions from code review
jkoritzinsky Dec 2, 2025
4669f81
Migrate to slnx
jkoritzinsky Dec 2, 2025
6327d92
PR feedback
jkoritzinsky Dec 4, 2025
c7ba930
PR feedback
jkoritzinsky Dec 5, 2025
5fc486b
Reduce unsafe to the minimum locations
jkoritzinsky Dec 5, 2025
fbc4aeb
Fix typo caught by code-anlysis
jkoritzinsky Dec 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion eng/Subsets.props
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@
<SubsetName Include="Tools.Cdac" Description="Diagnostic data contract reader and related projects." />
<SubsetName Include="Tools.ILLinkTests" OnDemand="true" Description="Unit tests for the tools.illink subset." />
<SubsetName Include="Tools.CdacTests" OnDemand="true" Description="Unit tests for the diagnostic data contract reader." />
<SubsetName Include="Tools.ILAsm" OnDemand="true" Description="Build only the managed ilasm tool." />

<!-- Host -->
<SubsetName Include="Host" Description="The .NET hosts, packages, hosting libraries, and tests. Equivalent to: $(DefaultHostSubsets)" />
Expand Down Expand Up @@ -510,7 +511,7 @@

<ItemGroup Condition="$(_subset.Contains('+tools.cdac+'))">
<ProjectToBuild Include="$(SharedNativeRoot)managed\compile-native.proj" Category="tools" />

<!-- Direct references to cDAC projects for packing -->
<ProjectToBuild Include="$(SharedNativeRoot)managed\cdac\Microsoft.Diagnostics.DataContractReader\Microsoft.Diagnostics.DataContractReader.csproj;
$(SharedNativeRoot)managed\cdac\Microsoft.Diagnostics.DataContractReader.Abstractions\Microsoft.Diagnostics.DataContractReader.Abstractions.csproj;
Expand Down Expand Up @@ -547,6 +548,11 @@
Test="true" Category="tools"/>
</ItemGroup>

<ItemGroup Condition="$(_subset.Contains('+tools.ilasm+'))">
<ProjectToBuild Include="$(ToolsProjectRoot)ilasm\ILAssembler\ILAssembler.csproj" Category="tools" />
<ProjectToBuild Include="$(ToolsProjectRoot)ilasm\ILAssembler.Tests\ILAssembler.Tests.csproj" Category="tools" Test="true" />
</ItemGroup>

<ItemGroup Condition="$(_subset.Contains('+clr.nativecorelib+'))">
<ProjectToBuild Include="$(CoreClrProjectRoot)crossgen-corelib.proj" Category="clr" />
</ItemGroup>
Expand Down
18 changes: 18 additions & 0 deletions eng/pipelines/coreclr/ilasm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pr:
include:
- src/coreclr/ilasm/*
- src/coreclr/ildasm/*
- src/tools/ilasm/*

schedules:
- cron: "0 19 * * 6"
Expand All @@ -32,3 +33,20 @@ extends:
- windows_x86
- windows_arm64
testGroup: ilasm

stages:
- stage: Managed_ILAsm
displayName: Managed IL Assembler Tests
dependsOn: []
jobs:
- template: /eng/pipelines/common/platform-matrix.yml
parameters:
jobTemplate: /eng/pipelines/common/global-build-job.yml
buildConfig: Debug
platforms:
- windows_x64
jobParameters:
nameSuffix: ILAsm
buildArgs: -s tools.ilasm -c $(_BuildConfig) -test
timeoutInMinutes: 120
condition: and(succeeded(), ne(variables['Build.Reason'], 'Schedule'))
5 changes: 5 additions & 0 deletions eng/pipelines/coreclr/templates/jit-outerloop-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ parameters:
- name: testGroup
type: string
default: outerloop
- name: stages
type: stageList
default: []

extends:
template: /eng/pipelines/common/templates/pipeline-with-resources.yml
Expand Down Expand Up @@ -55,3 +58,5 @@ extends:
testGroup: ${{ parameters.testGroup }}
liveLibrariesBuildConfig: Release
unifiedArtifactsName: BuildArtifacts_$(osGroup)$(osSubgroup)_$(archType)_$(_BuildConfig)
- ${{ each stage in parameters.stages }}:
- ${{ stage }}
53 changes: 53 additions & 0 deletions src/tools/ilasm/ILAssembler.Tests/DocumentCompilerTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using System.Reflection.PortableExecutable;
using System.Text;
using System.Threading.Tasks;
using Xunit;

namespace ILAssembler.Tests
{
public class DocumentCompilerTests
{
[Fact]
public void SingleTypeNoMembers()
{
string source = """
.class public auto ansi sealed beforefieldinit Test
{
}
""";

using var pe = CompileAndGetReader(source, new Options());
var reader = pe.GetMetadataReader();

// One for the <Module> type, one for Test.
Assert.Equal(2, reader.TypeDefinitions.Count);
var typeDef = reader.GetTypeDefinition(MetadataTokens.TypeDefinitionHandle(2));
Assert.Equal(string.Empty, reader.GetString(typeDef.Namespace));
Assert.Equal("Test", reader.GetString(typeDef.Name));
}

private static PEReader CompileAndGetReader(string source, Options options)
{
var sourceText = new SourceText(source, "test.il");
var documentCompiler = new DocumentCompiler();
var (diagnostics, result) = documentCompiler.Compile(sourceText, _ =>
{
Assert.Fail("Expected no includes");
return default;
}, _ => { Assert.Fail("Expected no resources"); return default; }, options);
Assert.Empty(diagnostics);
Assert.NotNull(result);
var blobBuilder = new BlobBuilder();
result!.Serialize(blobBuilder);
return new PEReader(blobBuilder.ToImmutableArray());
}
}
}
14 changes: 14 additions & 0 deletions src/tools/ilasm/ILAssembler.Tests/ILAssembler.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>$(NetCoreAppToolCurrent)</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\ILAssembler\ILAssembler.csproj" />
</ItemGroup>
</Project>
Loading
Loading