Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
256d279
bumps Cecilifier version to 2.28
adrianoc May 31, 2026
e53aa6d
refact: code cleanup
adrianoc May 31, 2026
4ad467a
refact: introduces CecilifierExtensions.AppendEnumFlags() taking Span…
adrianoc Jun 1, 2026
77f90c8
feat: support for generic type parameter constraints on generic types…
adrianoc Jun 3, 2026
d5b489e
refactor: Renames ITypeResolver.ResolveAny() -> Resolve()
adrianoc Jun 3, 2026
88fb877
fix: CoContraVariance tests (partially) under System.Reflection.Metad…
adrianoc Jun 3, 2026
18703d3
fix: generic types defined in external assemblies (#363)
adrianoc Jun 4, 2026
bf265d1
fix: invocation of generic methods defined in external assemblies (#364)
adrianoc Jun 5, 2026
ed79663
refact: code cleanup
adrianoc Jun 5, 2026
614ba87
feat: improves generic type parameter resolution and enables related …
adrianoc Jun 5, 2026
fe113e2
test: enables simple test for generic method invocation (#364)
adrianoc Jun 5, 2026
441e064
feat: fixes generic method handling and enables 'GenericMethods' inte…
adrianoc Jun 7, 2026
00c8d3c
doc: minor doc improvements (#364)
adrianoc Jun 7, 2026
39eb3b8
feat: cache variables holding method instantiations to avoid code dup…
adrianoc Jun 7, 2026
2f09c0f
test: enables a couple of tests that are passing due to previous chan…
adrianoc Jun 7, 2026
8c4179f
fix: use valid identifiers for variable names
adrianoc Jun 8, 2026
23d9070
fix: various fixes for generic instance methods (#364)
adrianoc Jun 9, 2026
8f98949
test: enables more generic method/property tests and introduces small…
adrianoc Jun 9, 2026
34a943b
feat: fixes last remaining test for 'value types' handling in System.…
adrianoc Jun 9, 2026
7f07702
remove failing test included by mistake
adrianoc Jun 9, 2026
d0f5340
feat: fixes a couple of places in event handling code generation assu…
adrianoc Jun 10, 2026
a382cb6
refact: refactoring towards using ApiDriver abstraction instead of as…
adrianoc Jun 10, 2026
4415e61
refact: move Utils.EnsureNotNull() method to SyntaxNodeExtensions (#368)
adrianoc Jun 10, 2026
14c5e81
refact: use ApiDriver abstraction instead of assuming Mono.Cecil targ…
adrianoc Jun 10, 2026
3ab97d8
refact: code cleanup
adrianoc Jun 10, 2026
29d6ab8
feat: adds support for simple instance/static events to System.Reflec…
adrianoc Jun 11, 2026
1eed12b
refact: replaced a bunch of hack checks to have different code paths …
adrianoc Jun 11, 2026
d7a485c
refact: improved documentation
adrianoc Jun 11, 2026
b04dd86
refact: change type of variable storing variable name of object abstr…
adrianoc Jun 12, 2026
4b53171
refact: rephrase comment to improve readbility
adrianoc Jun 12, 2026
c4ff012
refact: abstracted away some code that was targeting Mono.Cecil.
adrianoc Jun 12, 2026
137e64f
refact: rename method to match its intent
adrianoc Jun 12, 2026
178301e
refact: remove outdated TODO.
adrianoc Jun 12, 2026
0c9e128
refact: use IlContext instead of strings
adrianoc Jun 13, 2026
eb2dbc8
test: changes tests to allow bypassing context based test filtering
adrianoc Jun 13, 2026
2ae9f7a
test: enable tests that got fixed as a side effect of some other chan…
adrianoc Jun 13, 2026
7236490
test: fixes a bunch of low haiging fruit tests (#358)
adrianoc Jun 14, 2026
6d3b641
test: fixes a bunch of either already working or low haiging fruit te…
adrianoc Jun 14, 2026
4e79ea5
test: enables a couple more of low hainging fruits tests (#358)
adrianoc Jun 15, 2026
8b255b8
test: enables a couple more of low hainging fruits tests (#358)
adrianoc Jun 15, 2026
2d1a115
refact: remove TypeExternsions.MakeByReferenceType() and redirect cal…
adrianoc Jun 15, 2026
d37ddd8
refact: clean ups a few Mono.Cecil specific code generation, replacin…
adrianoc Jun 15, 2026
9aea37b
fix: call on generic type parameters (#358)
adrianoc Jun 16, 2026
d65ffed
feat: introduces ITypeResolver.ResolveTypeParameter() to be used when…
adrianoc Jun 18, 2026
ca9a6d1
doc: improve api docs a little bit
adrianoc Jun 18, 2026
0aad861
fix: moves IlContext creation so it can be used when emitting the rel…
adrianoc Jun 18, 2026
f43d585
fix: types resolved by 'ITypeResolver.Bcl' needs extra code to be use…
adrianoc Jun 18, 2026
19e413d
refact: code cleanup and minor improvements on debugger visualization…
adrianoc Jun 19, 2026
4753af7
feat: take generic type parameters into account when registering/look…
adrianoc Jun 19, 2026
b61d67a
fix: issue in which local variables were being added to the incorrect…
adrianoc Jun 19, 2026
7e95154
feat: introduces 'IMemberResolver.MakeGenericInstanceMethod()' and re…
adrianoc Jun 19, 2026
aaaa354
feat: multiple fixes to get 'TestInlineArrays' passing on SRM (#358)
adrianoc Jun 19, 2026
4ca6a68
refact: more code cleanup
adrianoc Jun 19, 2026
9c98727
refact: remove some code duplication (#358)
adrianoc Jun 19, 2026
f857931
fix: fix invalid code generation in Mono.Cecil and a couple of other …
adrianoc Jun 20, 2026
531ef25
wip
adrianoc Jun 21, 2026
495a338
feat: various changes for supporting generic inline arrays and indexi…
adrianoc Jun 22, 2026
d31f9f0
feat: enables DllImport integration tests on SRM (#358)
adrianoc Jun 23, 2026
11361a8
test: improve assembly comparison code (#358)
adrianoc Jun 23, 2026
25d6d12
refact: ApiDriver required changes to add exception handling support …
adrianoc Jun 23, 2026
242f3ab
feat: add suport for exception handling in SRM (#358)
adrianoc Aug 28, 2026
2094105
fix: use correct size when encoding indexes used in instruction opera…
adrianoc Aug 29, 2026
8a54211
feat: multiple changes to support a couple of C# statements in SRM (#…
adrianoc Aug 29, 2026
8553ce2
refact: minor code generation / naming improvements (#358)
adrianoc Aug 30, 2026
336c9a5
feat: reenabled and fixes ref parameters implementation in SRM (#358)
adrianoc Aug 30, 2026
b707414
fix: use base method in invocations of virtual methods on non value t…
adrianoc Aug 30, 2026
d4f1732
test: enable all TypeTestCase on SRM (#358)
adrianoc Aug 30, 2026
e5c0175
test: enable all FieldTests output based tests on SRM (#358)
adrianoc Aug 30, 2026
7ea12a3
test: enable most InvocationTests output based tests on SRM (#358)
adrianoc Aug 30, 2026
9045543
test: enable/fix TestExpressionBodiedMembers and introduces DisableFo…
adrianoc Sep 1, 2026
ef17146
feat: coalescing operator support for SRM (#358)
adrianoc Sep 4, 2026
dd78c61
targets net10.0
adrianoc Sep 6, 2026
4ae05e1
we are in 2026 already :)
adrianoc Sep 6, 2026
45f450b
adds a basic guided tour
adrianoc Sep 7, 2026
84405c5
improve guided tour wording and fixes reference dialog not closing
adrianoc Sep 9, 2026
bd2720f
updates packages
adrianoc Sep 11, 2026
72d668c
fix: improves nested type resolution (#358)
adrianoc Sep 16, 2026
286912a
test: ensure all integration/output based tests are configured to run…
adrianoc Sep 16, 2026
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
4 changes: 2 additions & 2 deletions .github/workflows/cecilifier-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
- run: dotnet tool install --global dotnet-ilverify --version 9.0.0
dotnet-version: '10.0.x'
- run: dotnet tool install --global dotnet-ilverify --version 10.0.12
- run: dotnet restore
- run: dotnet test --filter 'TestCategory !~ Issues' --collect:"XPlat Code Coverage"
- run: dotnet format style --verify-no-changes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="../Cecilifier.Common.props" />
<Import Project="../Cecilifier.CommonPackages.props" />

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
3 changes: 2 additions & 1 deletion Cecilifier.ApiDriver.MonoCecil/MonoCecilContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ public MonoCecilContext(CecilifierOptions options, SemanticModel semanticModel,
public static IVisitorContext CreateContext(CecilifierOptions options, SemanticModel semanticModel) => new MonoCecilContext(options, semanticModel);
public static string[] BclAssembliesForCompilation()
{
return ((string) AppContext.GetData("TRUSTED_PLATFORM_ASSEMBLIES")).Split(Path.PathSeparator);
var data = AppContext.GetData("TRUSTED_PLATFORM_ASSEMBLIES");
return data != null ? ((string) data).Split(Path.PathSeparator) : Array.Empty<string>();
}

public static string[] GetPreprocessorSymbols() => ["API_DRIVER_MONO_CECIL"];
Expand Down
28 changes: 23 additions & 5 deletions Cecilifier.ApiDriver.MonoCecil/MonoCecilDeferredIlContext.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Diagnostics;
using Cecilifier.Core.AST;

namespace Cecilifier.ApiDriver.MonoCecil;
Expand All @@ -6,25 +7,42 @@ public class MonoCecilDeferredIlContext : IlContext
{
private readonly IVisitorContext _context;
private bool _emitted;
#if DEBUG_MATERIALIZATION_CHECK
private string _debugInfo;
#endif

protected internal MonoCecilDeferredIlContext(IVisitorContext context, string ilVarName, string relatedMethodVar) : base(ilVarName, relatedMethodVar)
{
_context = context;
_emitted = false;

#if DEBUG_MATERIALIZATION_CHECK
_debugInfo = new StackTrace(true).ToString();
#endif
}

public override string VariableName
{
get
{
#if DEBUG_MATERIALIZATION_CHECK
if (!_emitted)
{
_emitted = true;
_context.Generate($"var {base.VariableName} = {AssociatedMethodVariable}.Body.GetILProcessor();");
_context.WriteNewLine();
}
throw new InvalidOperationException($"IL context is not materialized yet\nIlContext instantiated at:\n{_debugInfo}\n----------------------------");
#else
Materialize();
#endif

return base.VariableName;
}
}

public override void Materialize()
{
if (!_emitted)
{
_emitted = true;
_context.Generate($"var {base.VariableName} = {AssociatedMethodVariable}.Body.GetILProcessor();");
_context.WriteNewLine();
}
}
}
187 changes: 168 additions & 19 deletions Cecilifier.ApiDriver.MonoCecil/MonoCecilDefinitionsFactory.cs

Large diffs are not rendered by default.

45 changes: 43 additions & 2 deletions Cecilifier.ApiDriver.MonoCecil/MonoCecilGeneratorDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Cecilifier.Core.AST;
using Cecilifier.Core.Extensions;
using Cecilifier.Core.TypeSystem;
using Cecilifier.Core.Variables;
using Microsoft.CodeAnalysis;

namespace Cecilifier.ApiDriver.MonoCecil;
Expand Down Expand Up @@ -54,6 +55,8 @@ public static void Main(string[] args)
}}";
}

public ApiDriverCapabilities DriverCapabilities => ApiDriverCapabilities.RequiresForwardReferences | ApiDriverCapabilities.RequiresExplicitParameterSyntaxHandling;

public int PreambleLineCount => 25; // The # of lines before the 1st cecilified line of code (see `cecilifiedCode` parameter from AsCecilApplication())

public IReadOnlyCollection<string> AssemblyReferences { get; } =
Expand Down Expand Up @@ -91,21 +94,31 @@ public void WriteCilInstruction(IVisitorContext context, IlContext il, OpCode op

public void WriteCilBranch(IVisitorContext context, IlContext il, OpCode branchOpCode, string targetLabel, string? comment = null)
{
WriteCilInstruction(context, il, branchOpCode, targetLabel, comment);
context.Generate(EmitCilInstruction(context, il, branchOpCode, targetLabel, comment));
context.WriteNewLine();
}

public string EmitCilBranchInstruction(IVisitorContext context, IlContext il, OpCode branchOpCode, string targetLabel, string? comment = null)
{
return EmitCilInstruction(context, il, branchOpCode, targetLabel, comment);
}

public void DefineLabel(IVisitorContext context, IlContext il, string labelVariable)
{
context.Generate($"var {labelVariable} = {il.VariableName}.Create(OpCodes.Nop);");
context.WriteNewLine();
}


public string EmitDefineLabel(IVisitorContext context, IlContext il, string labelVariable) => $"var {labelVariable} = {il.VariableName}.Create(OpCodes.Nop);";

public void MarkLabel(IVisitorContext context, IlContext il, string labelVariable)
{
context.Generate($"{il.VariableName}.Append({labelVariable});");
context.WriteNewLine();
}

public string EmitMarkLabel(IVisitorContext context, IlContext il, string labelVariable) => $"{il.VariableName}.Append({labelVariable});";

public IlContext NewIlContext(IVisitorContext context, string memberName, string relatedMethodVar)
{
var ilVarName = context.Naming.ILProcessor(memberName);
Expand All @@ -128,4 +141,32 @@ public void AddMethodSemantics(IVisitorContext context, string targetVariable, s
$"{methodVariable}.Body = new MethodBody({methodVariable});",
$"{targetVariable}.{accessor} = {methodVariable};" ]);
}

public void WriteExceptionHandlers(IVisitorContext context, IlContext ilVar, IEnumerable<ExceptionHandlerEntry> exceptionHandlerTable)
{
string methodVar = context.DefinitionVariables.GetLastOf(VariableMemberKind.Method);
foreach (var handlerEntry in exceptionHandlerTable)
{
context.Generate($"{methodVar}.Body.ExceptionHandlers.Add(new ExceptionHandler(ExceptionHandlerType.{handlerEntry.Kind})");
context.WriteNewLine();
context.Generate("{");
context.WriteNewLine();
if (handlerEntry.Kind == ExceptionHandlerKind.Catch)
{
context.Generate($" CatchType = {handlerEntry.CatchType},");
context.WriteNewLine();
}

context.Generate($" TryStart = {handlerEntry.TryStart},");
context.WriteNewLine();
context.Generate($" TryEnd = {handlerEntry.TryEnd},");
context.WriteNewLine();
context.Generate($" HandlerStart = {handlerEntry.HandlerStart},");
context.WriteNewLine();
context.Generate($" HandlerEnd = {handlerEntry.HandlerEnd}");
context.WriteNewLine();
context.Generate("});");
context.WriteNewLine();
}
}
}
Loading
Loading