mirror of
https://github.com/icsharpcode/ILSpy.git
synced 2026-10-12 02:15:58 +00:00
Fix five small analyzer warnings.
* ExtensionDeclaration.SymbolKind (CA1065) — was throwing
NotImplementedException; return SymbolKind.TypeDefinition to match
TypeDeclaration / DelegateDeclaration, since `extension` declarations
are type-level.
* CustomAttribute.DecodeValue (CA2002) — replace `lock(this)` on the
sealed-but-internal class with a private syncRoot field.
* PlainTextOutput (CA1001) — implement IDisposable; track an
ownsWriter flag so we only dispose the underlying TextWriter when
the parameterless constructor created its own StringWriter.
* DotNetCorePathFinder (CA1060) — move the libc realpath / free
PInvokes into a private nested NativeMethods class.
* ILSpy.ReadyToRun (CA1016) — add [assembly: AssemblyVersion("1.0.0.0")]
in Properties/AssemblyInfo.cs to match the BamlDecompiler plugin.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
784379d012
commit
317e33b3b8
@@ -24,7 +24,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
|
||||
{
|
||||
public readonly static TokenRole ExtensionKeywordRole = new TokenRole("extension");
|
||||
|
||||
public override SymbolKind SymbolKind => throw new System.NotImplementedException();
|
||||
public override SymbolKind SymbolKind => SymbolKind.TypeDefinition;
|
||||
|
||||
public AstNodeCollection<TypeParameterDeclaration> TypeParameters {
|
||||
get { return GetChildrenByRole(Roles.TypeParameter); }
|
||||
|
||||
@@ -318,7 +318,7 @@ namespace ICSharpCode.Decompiler.Metadata
|
||||
fixed (byte* input = bytes)
|
||||
{
|
||||
|
||||
byte* output = GetRealPath(input, null);
|
||||
byte* output = NativeMethods.GetRealPath(input, null);
|
||||
if (output == null)
|
||||
{
|
||||
return null;
|
||||
@@ -330,15 +330,18 @@ namespace ICSharpCode.Decompiler.Metadata
|
||||
}
|
||||
byte[] result = new byte[len];
|
||||
Marshal.Copy((IntPtr)output, result, 0, result.Length);
|
||||
Free(output);
|
||||
NativeMethods.Free(output);
|
||||
return encoding.GetString(result);
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("libc", EntryPoint = "realpath")]
|
||||
static extern unsafe byte* GetRealPath(byte* path, byte* resolvedPath);
|
||||
static class NativeMethods
|
||||
{
|
||||
[DllImport("libc", EntryPoint = "realpath")]
|
||||
internal static extern unsafe byte* GetRealPath(byte* path, byte* resolvedPath);
|
||||
|
||||
[DllImport("libc", EntryPoint = "free")]
|
||||
static extern unsafe void Free(void* ptr);
|
||||
[DllImport("libc", EntryPoint = "free")]
|
||||
internal static extern unsafe void Free(void* ptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,9 +28,10 @@ using ICSharpCode.Decompiler.TypeSystem;
|
||||
|
||||
namespace ICSharpCode.Decompiler
|
||||
{
|
||||
public sealed class PlainTextOutput : ITextOutput
|
||||
public sealed class PlainTextOutput : ITextOutput, IDisposable
|
||||
{
|
||||
readonly TextWriter writer;
|
||||
readonly bool ownsWriter;
|
||||
int indent;
|
||||
bool needsIndent;
|
||||
|
||||
@@ -44,11 +45,19 @@ namespace ICSharpCode.Decompiler
|
||||
if (writer == null)
|
||||
throw new ArgumentNullException(nameof(writer));
|
||||
this.writer = writer;
|
||||
this.ownsWriter = false;
|
||||
}
|
||||
|
||||
public PlainTextOutput()
|
||||
{
|
||||
this.writer = new StringWriter();
|
||||
this.ownsWriter = true;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (ownsWriter)
|
||||
writer.Dispose();
|
||||
}
|
||||
|
||||
public TextLocation Location {
|
||||
|
||||
@@ -40,6 +40,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
|
||||
CustomAttributeValue<IType> value;
|
||||
bool valueDecoded;
|
||||
bool hasDecodeErrors;
|
||||
readonly object syncRoot = new object();
|
||||
|
||||
internal CustomAttribute(MetadataModule module, IMethod attrCtor, CustomAttributeHandle handle)
|
||||
{
|
||||
@@ -76,7 +77,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
|
||||
|
||||
void DecodeValue()
|
||||
{
|
||||
lock (this)
|
||||
lock (syncRoot)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -8,7 +8,8 @@ using System.Runtime.Versioning;
|
||||
[assembly: TargetPlatform("Windows10.0")]
|
||||
[assembly: SupportedOSPlatform("Windows7.0")]
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: NeutralResourcesLanguage("en-US")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
|
||||
Reference in New Issue
Block a user