Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/build-ilspy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:

- name: Install dotnet-format
env:
DOTNET_FORMAT_VERSION: 10.0.100-preview.7.25380.108
DOTNET_FORMAT_VERSION: 10.0.100-rc.1.25451.107
DOTNET_FORMAT_SOURCE: https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet10-transport/nuget/v3/index.json
run: dotnet tool install -g dotnet-format --version "${{env.DOTNET_FORMAT_VERSION}}" --add-source "${{env.DOTNET_FORMAT_SOURCE}}"

Expand Down
2 changes: 1 addition & 1 deletion BuildTools/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

set -eu

DOTNET_FORMAT_VERSION=10.0.100-preview.7.25380.108
DOTNET_FORMAT_VERSION=10.0.100-rc.1.25451.107
DOTNET_FORMAT_SOURCE="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet10-transport/nuget/v3/index.json"
DOTNET_PATH="$LOCALAPPDATA/ICSharpCode/ILSpy/dotnet-format-$DOTNET_FORMAT_VERSION"
if [ ! -d "$DOTNET_PATH" ]; then
Expand Down
34 changes: 17 additions & 17 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
<ItemGroup>
<PackageVersion Include="AvalonEdit" Version="6.3.1.120" />
<PackageVersion Include="CliWrap" Version="3.9.0" />
<PackageVersion Include="DataGridExtensions" Version="2.6.0" />
<PackageVersion Include="DataGridExtensions" Version="2.7.0" />
<PackageVersion Include="DiffLib" Version="2025.0.0" />
<PackageVersion Include="Dirkster.AvalonDock.Themes.VS2013" Version="4.72.1" />
<PackageVersion Include="ILCompiler.Reflection.ReadyToRun.Experimental" Version="10.0.0-preview.7.25380.108" />
<PackageVersion Include="ILCompiler.Reflection.ReadyToRun.Experimental" Version="10.0.0-rc.1.25451.107" />
<PackageVersion Include="Iced" Version="1.21.0" />
<PackageVersion Include="K4os.Compression.LZ4" Version="1.3.8" />
<PackageVersion Include="McMaster.Extensions.CommandLineUtils" Version="4.1.1" />
Expand All @@ -19,17 +19,17 @@
<PackageVersion Include="Microsoft.DiaSymReader.Converter.Xml" Version="1.1.0-beta2-22171-02" />
<PackageVersion Include="Microsoft.DiaSymReader" Version="1.4.0" />
<PackageVersion Include="Microsoft.DiaSymReader.Native" Version="17.0.0-beta1.21524.1" />
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="10.0.0-preview.7.25380.108" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="10.0.0-preview.7.25380.108" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.0-preview.7.25380.108" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="10.0.0-preview.7.25380.108" />
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="10.0.0-rc.1.25451.107" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="10.0.0-rc.1.25451.107" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.0-rc.1.25451.107" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="10.0.0-rc.1.25451.107" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageVersion Include="Microsoft.NETCore.ILAsm" Version="10.0.0-preview.7.25380.108" />
<PackageVersion Include="Microsoft.NETCore.ILDAsm" Version="10.0.0-preview.7.25380.108" />
<PackageVersion Include="Microsoft.Sbom.Targets" Version="4.1.0" />
<PackageVersion Include="Microsoft.NETCore.ILAsm" Version="10.0.0-rc.1.25451.107" />
<PackageVersion Include="Microsoft.NETCore.ILDAsm" Version="10.0.0-rc.1.25451.107" />
<PackageVersion Include="Microsoft.Sbom.Targets" Version="4.1.2" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
<PackageVersion Include="Microsoft.Testing.Extensions.TrxReport" Version="1.8.2" />
<PackageVersion Include="Microsoft.Testing.Extensions.VSTestBridge" Version="1.8.2" />
<PackageVersion Include="Microsoft.Testing.Extensions.TrxReport" Version="1.8.4" />
<PackageVersion Include="Microsoft.Testing.Extensions.VSTestBridge" Version="1.8.4" />
<PackageVersion Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.135" />
<PackageVersion Include="Mono.Cecil" Version="0.11.6" />
<PackageVersion Include="NSubstitute" Version="5.3.0" />
Expand All @@ -39,13 +39,13 @@
<PackageVersion Include="NuGet.Protocol" Version="6.14.0" />
<PackageVersion Include="PowerShellStandard.Library" Version="5.1.1" />
<PackageVersion Include="Shouldly" Version="4.3.0" />
<PackageVersion Include="System.Composition.AttributedModel" Version="10.0.0-preview.7.25380.108" />
<PackageVersion Include="System.Collections.Immutable" Version="10.0.0-preview.7.25380.108" />
<PackageVersion Include="System.Composition.AttributedModel" Version="10.0.0-rc.1.25451.107" />
<PackageVersion Include="System.Collections.Immutable" Version="10.0.0-rc.1.25451.107" />
<PackageVersion Include="System.Memory" Version="4.6.3" />
<PackageVersion Include="System.Reflection.Metadata" Version="10.0.0-preview.7.25380.108" />
<PackageVersion Include="System.Resources.Extensions" Version="10.0.0-preview.7.25380.108" />
<PackageVersion Include="System.Reflection.Metadata" Version="10.0.0-rc.1.25451.107" />
<PackageVersion Include="System.Resources.Extensions" Version="10.0.0-rc.1.25451.107" />
<PackageVersion Include="System.Runtime.CompilerServices.Unsafe" Version="6.1.2" />
<PackageVersion Include="System.Security.Cryptography.Pkcs" Version="9.0.8" />
<PackageVersion Include="System.Security.Cryptography.Pkcs" Version="9.0.9" />
<PackageVersion Include="TomsToolbox.Composition.MicrosoftExtensions" Version="2.22.2" />
<PackageVersion Include="TomsToolbox.Wpf.Composition" Version="2.22.2" />
<PackageVersion Include="TomsToolbox.Wpf.Composition.AttributedModel" Version="2.22.2" />
Expand All @@ -56,6 +56,6 @@
<PackageVersion Include="System.Text.RegularExpressions" Version="4.3.1" />
</ItemGroup>
<ItemGroup>
<GlobalPackageReference Include="TomsToolbox.Composition.Analyzer" Version="2.22.1" />
<GlobalPackageReference Include="TomsToolbox.Composition.Analyzer" Version="2.22.2" />
</ItemGroup>
</Project>
16 changes: 8 additions & 8 deletions ICSharpCode.BamlDecompiler/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
"net10.0": {
"Microsoft.Sbom.Targets": {
"type": "Direct",
"requested": "[4.1.0, )",
"resolved": "4.1.0",
"contentHash": "GidfeSVHFtNwZSbD2wmwWiUiGkVdND8QR1z21WpFa+/47Mi3YiDkAzsWF02wXrMx2Xd8j3QSfKOUY1JtnF+7uw=="
"requested": "[4.1.2, )",
"resolved": "4.1.2",
"contentHash": "AmGCBhWtWu1d1PCit6WTdmpq48nPmmnJz9zZFBsxoCjYZjjZ0Gjm+wuAzHzVMF8VmTo/NeDGi2C73969QXiryw=="
},
"TomsToolbox.Composition.Analyzer": {
"type": "Direct",
"requested": "[2.22.1, )",
"resolved": "2.22.1",
"contentHash": "bKcte9zaz+xH1k6C1YIYpheQ9mPNRSmd0dHQIEIq31KxAKMTLfiAo80aROKDJMYJ7ZomlUjjSMo/QCIikMMWTg=="
"requested": "[2.22.2, )",
"resolved": "2.22.2",
"contentHash": "7gYo8ZR2eq3XkrilvUpLbTypeZy6IlD5FB8jah0YPhMOmDGhya4jJ3kfDMTTRt5m258Ou78P69mHMkG6DKZXsg=="
},
"icsharpcode.decompiler": {
"type": "Project",
Expand All @@ -23,13 +23,13 @@
},
"System.Collections.Immutable": {
"type": "CentralTransitive",
"requested": "[10.0.0-preview.7.25380.108, )",
"requested": "[10.0.0-rc.1.25451.107, )",
"resolved": "9.0.0",
"contentHash": "QhkXUl2gNrQtvPmtBTQHb0YsUrDiDQ2QS09YbtTTiSjGcf7NBqtYbrG/BE06zcBPCKEwQGzIv13IVdXNOSub2w=="
},
"System.Reflection.Metadata": {
"type": "CentralTransitive",
"requested": "[10.0.0-preview.7.25380.108, )",
"requested": "[10.0.0-rc.1.25451.107, )",
"resolved": "9.0.0",
"contentHash": "ANiqLu3DxW9kol/hMmTWbt3414t9ftdIuiIU7j80okq2YzAueo120M442xk1kDJWtmZTqWQn7wHDvMRipVOEOQ=="
}
Expand Down
6 changes: 3 additions & 3 deletions ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1436,7 +1436,7 @@ EntityDeclaration DoDecompile(ITypeDefinition typeDef, DecompileRun decompileRun
}
if (settings.RequiredMembers)
{
RemoveAttribute(typeDecl, KnownAttribute.RequiredAttribute);
RemoveAttribute(typeDecl, KnownAttribute.Required);
}
if (typeDecl.ClassType == ClassType.Enum)
{
Expand Down Expand Up @@ -2016,7 +2016,7 @@ EntityDeclaration DoDecompile(IField field, DecompileRun decompileRun, ITypeReso
typeSystemAstBuilder.UseSpecialConstants = !(field.DeclaringType.Equals(field.ReturnType) || isMathPIOrE);
var fieldDecl = typeSystemAstBuilder.ConvertEntity(field);
SetNewModifier(fieldDecl);
if (settings.RequiredMembers && RemoveAttribute(fieldDecl, KnownAttribute.RequiredAttribute))
if (settings.RequiredMembers && RemoveAttribute(fieldDecl, KnownAttribute.Required))
{
fieldDecl.Modifiers |= Modifiers.Required;
}
Expand Down Expand Up @@ -2132,7 +2132,7 @@ EntityDeclaration DoDecompile(IProperty property, DecompileRun decompileRun, ITy
propertyDecl.Modifiers &= ~(Modifiers.New | Modifiers.Virtual);
propertyDecl.Modifiers |= Modifiers.Override;
}
if (settings.RequiredMembers && RemoveAttribute(propertyDecl, KnownAttribute.RequiredAttribute))
if (settings.RequiredMembers && RemoveAttribute(propertyDecl, KnownAttribute.Required))
{
propertyDecl.Modifiers |= Modifiers.Required;
}
Expand Down
61 changes: 58 additions & 3 deletions ICSharpCode.Decompiler/TypeSystem/ExtensionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#nullable enable

using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Metadata;
Expand All @@ -37,11 +38,21 @@ public ExtensionInfo(MetadataModule module, ITypeDefinition extensionContainer)
var metadata = module.MetadataFile.Metadata;

foreach (var extGroup in extensionContainer.NestedTypes)
{
if (TryEncodingV1(extGroup))
{
continue;
}

TryEncodingV2(extGroup);
}

bool TryEncodingV1(ITypeDefinition extGroup)
{
if (!(extGroup is { Kind: TypeKind.Class, IsSealed: true }
&& extGroup.Name.StartsWith("<>E__", System.StringComparison.Ordinal)))
{
continue;
return false;
}

TypeDefinition td = metadata.GetTypeDefinition((TypeDefinitionHandle)extGroup.MetadataToken);
Expand Down Expand Up @@ -69,8 +80,53 @@ public ExtensionInfo(MetadataModule module, ITypeDefinition extensionContainer)
}

if (marker == null || hasMultipleMarkers)
continue;
return false;

CollectImplementationMethods(extGroup, marker, extensionMethods);
return true;
}

bool TryEncodingV2(ITypeDefinition extGroup)
{
if (!(extGroup is { Kind: TypeKind.Class, IsSealed: true }
&& extGroup.Name.StartsWith("<G>$", StringComparison.Ordinal)))
{
return false;
}

var markerType = extGroup.NestedTypes.SingleOrDefault(t => t.Name.StartsWith("<M>$", StringComparison.Ordinal) && t.IsStatic);
var marker = markerType?.Methods.SingleOrDefault(m => m.Name == "<Extension>$" && m.IsStatic && m.Parameters.Count == 1);

if (markerType == null || marker == null)
return false;

TypeDefinition td = metadata.GetTypeDefinition((TypeDefinitionHandle)extGroup.MetadataToken);
List<IMethod> extensionMethods = [];

// For easier access to accessors we use SRM
foreach (var h in td.GetMethods())
{
var method = module.GetDefinition(h);

if (method.SymbolKind is SymbolKind.Constructor)
continue;

var attribute = method.GetAttribute(KnownAttribute.ExtensionMarker);
if (attribute == null)
continue;

if (attribute.FixedArguments[0].Value?.ToString() != markerType.Name)
continue;

extensionMethods.Add(method);
}

CollectImplementationMethods(extGroup, marker, extensionMethods);
return true;
}

void CollectImplementationMethods(ITypeDefinition extGroup, IMethod marker, List<IMethod> extensionMethods)
{
foreach (var extension in extensionMethods)
{
int expectedTypeParameterCount = extension.TypeParameters.Count + extGroup.TypeParameterCount;
Expand Down Expand Up @@ -119,7 +175,6 @@ bool IsMatchingImplementation(IMethod impl)
}
}
}

}

public ExtensionMemberInfo? InfoOfExtensionMember(IMethod method)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,18 @@ public enum KnownAttribute
PreserveBaseOverrides,

// C# 11 attributes:
RequiredAttribute,
Required,

// C# 12 attributes:
InlineArray,

// C# 14 attributes:
ExtensionMarker,
}

public static class KnownAttributes
{
internal const int Count = (int)KnownAttribute.InlineArray + 1;
internal const int Count = (int)KnownAttribute.ExtensionMarker + 1;

static readonly TopLevelTypeName[] typeNames = new TopLevelTypeName[Count]{
default,
Expand Down Expand Up @@ -193,6 +196,8 @@ public static class KnownAttributes
new TopLevelTypeName("System.Runtime.CompilerServices", "RequiredMemberAttribute"),
// C# 12 attributes:
new TopLevelTypeName("System.Runtime.CompilerServices", "InlineArrayAttribute"),
// C# 14 attributes:
new TopLevelTypeName("System.Runtime.CompilerServices", "ExtensionMarkerAttribute"),
};

public static ref readonly TopLevelTypeName GetTypeName(this KnownAttribute attr)
Expand Down
Loading
Loading