diff --git a/.editorconfig b/.editorconfig index f456380ee..06fbf7f64 100644 --- a/.editorconfig +++ b/.editorconfig @@ -208,6 +208,70 @@ dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent # Errors and warnings +dotnet_diagnostic.IDE0007.severity = none + +dotnet_diagnostic.CA1001.severity = warning +dotnet_diagnostic.CA1009.severity = warning +dotnet_diagnostic.CA1016.severity = warning +#dotnet_diagnostic.CA1033.severity = warning # Disabled because currently, there are too many violations +dotnet_diagnostic.CA1049.severity = warning +dotnet_diagnostic.CA1060.severity = warning +dotnet_diagnostic.CA1061.severity = warning +dotnet_diagnostic.CA1063.severity = warning +dotnet_diagnostic.CA1065.severity = warning +dotnet_diagnostic.CA1301.severity = warning +dotnet_diagnostic.CA1400.severity = warning +dotnet_diagnostic.CA1401.severity = warning +dotnet_diagnostic.CA1403.severity = warning +dotnet_diagnostic.CA1404.severity = warning +dotnet_diagnostic.CA1405.severity = warning +dotnet_diagnostic.CA1410.severity = warning +dotnet_diagnostic.CA1415.severity = warning +dotnet_diagnostic.CA1821.severity = warning +dotnet_diagnostic.CA1900.severity = warning +dotnet_diagnostic.CA1901.severity = warning +dotnet_diagnostic.CA2002.severity = warning +dotnet_diagnostic.CA2100.severity = warning +dotnet_diagnostic.CA2101.severity = warning +dotnet_diagnostic.CA2108.severity = warning +dotnet_diagnostic.CA2111.severity = warning +dotnet_diagnostic.CA2112.severity = warning +dotnet_diagnostic.CA2114.severity = warning +dotnet_diagnostic.CA2116.severity = warning +dotnet_diagnostic.CA2117.severity = warning +dotnet_diagnostic.CA2122.severity = warning +dotnet_diagnostic.CA2123.severity = warning +dotnet_diagnostic.CA2124.severity = warning +dotnet_diagnostic.CA2126.severity = warning +dotnet_diagnostic.CA2131.severity = warning +dotnet_diagnostic.CA2132.severity = warning +dotnet_diagnostic.CA2133.severity = warning +dotnet_diagnostic.CA2134.severity = warning +dotnet_diagnostic.CA2137.severity = warning +dotnet_diagnostic.CA2138.severity = warning +dotnet_diagnostic.CA2140.severity = warning +dotnet_diagnostic.CA2141.severity = warning +dotnet_diagnostic.CA2146.severity = warning +dotnet_diagnostic.CA2147.severity = warning +dotnet_diagnostic.CA2149.severity = warning +dotnet_diagnostic.CA2200.severity = warning +dotnet_diagnostic.CA2202.severity = warning +dotnet_diagnostic.CA2207.severity = warning +dotnet_diagnostic.CA2212.severity = warning +dotnet_diagnostic.CA2213.severity = warning +dotnet_diagnostic.CA2214.severity = warning +dotnet_diagnostic.CA2216.severity = warning +dotnet_diagnostic.CA2220.severity = warning +dotnet_diagnostic.CA2229.severity = warning +dotnet_diagnostic.CA2231.severity = warning +dotnet_diagnostic.CA2232.severity = warning +dotnet_diagnostic.CA2235.severity = warning +dotnet_diagnostic.CA2236.severity = warning +dotnet_diagnostic.CA2237.severity = warning +dotnet_diagnostic.CA2238.severity = warning +dotnet_diagnostic.CA2240.severity = warning +dotnet_diagnostic.CA2241.severity = warning +dotnet_diagnostic.CA2242.severity = warning # MEF006: No importing constructor dotnet_diagnostic.MEF006.severity = silent diff --git a/BuildTools/bom-strip.ps1 b/BuildTools/bom-strip.ps1 index 0f92d6195..e5b8db264 100644 --- a/BuildTools/bom-strip.ps1 +++ b/BuildTools/bom-strip.ps1 @@ -29,7 +29,7 @@ $Dotfiles = @( $AllowedExts = @( '.bat','.config','.cs','.csproj','.css','.filelist','.fs','.html','.il', '.ipynb','.js','.json','.less','.manifest','.md','.projitems','.props', - '.ps1','.psd1','.ruleset','.shproj','.sln','.slnf','.svg','.template', + '.ps1','.psd1','.shproj','.sln','.slnf','.svg','.template', '.tt', '.txt','.vb','.vsct','.vsixlangpack','.wxl','.xaml','.xml','.xshd','.yml' ) diff --git a/Directory.Packages.props b/Directory.Packages.props index ec3940f3c..da3f2ea77 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -57,5 +57,9 @@ + + all + runtime; build; native; contentfiles; analyzers + \ No newline at end of file diff --git a/ICSharpCode.BamlDecompiler/ICSharpCode.BamlDecompiler.csproj b/ICSharpCode.BamlDecompiler/ICSharpCode.BamlDecompiler.csproj index 2e224a62f..d95542e3f 100644 --- a/ICSharpCode.BamlDecompiler/ICSharpCode.BamlDecompiler.csproj +++ b/ICSharpCode.BamlDecompiler/ICSharpCode.BamlDecompiler.csproj @@ -1,4 +1,4 @@ - + net10.0 @@ -47,10 +47,6 @@ true - - - - diff --git a/ICSharpCode.BamlDecompiler/Properties/AssemblyInfo.cs b/ICSharpCode.BamlDecompiler/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..ebab78e31 --- /dev/null +++ b/ICSharpCode.BamlDecompiler/Properties/AssemblyInfo.cs @@ -0,0 +1,21 @@ +#region Using directives + +using System.Diagnostics.CodeAnalysis; +using System.Reflection; +using System.Runtime.InteropServices; + +#endregion + +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// This sets the default COM visibility of types in the assembly to invisible. +// If you need to expose a type to COM, use [ComVisible(true)] on that type. +[assembly: ComVisible(false)] + +[assembly: AssemblyVersion(DecompilerVersionInfo.Major + "." + DecompilerVersionInfo.Minor + "." + DecompilerVersionInfo.Build + "." + DecompilerVersionInfo.Revision)] +[assembly: AssemblyInformationalVersion(DecompilerVersionInfo.FullVersionWithCommitHash)] + +[assembly: SuppressMessage("Microsoft.Usage", "CA2243:AttributeStringLiteralsShouldParseCorrectly", + Justification = "AssemblyInformationalVersion does not need to be a parsable version")] + diff --git a/ICSharpCode.BamlDecompiler/packages.lock.json b/ICSharpCode.BamlDecompiler/packages.lock.json index e93454460..98e57785d 100644 --- a/ICSharpCode.BamlDecompiler/packages.lock.json +++ b/ICSharpCode.BamlDecompiler/packages.lock.json @@ -2,6 +2,12 @@ "version": 2, "dependencies": { "net10.0": { + "Microsoft.CodeAnalysis.NetAnalyzers": { + "type": "Direct", + "requested": "[10.0.100, )", + "resolved": "10.0.100", + "contentHash": "uj9VuyvqylnNueJfU7u2PkI/hEMpZl8Wg9BXyI0eatNEldU5jDYPdwsM8aDL18+1oLovju25MiqOPaGRBnG72A==" + }, "Microsoft.Sbom.Targets": { "type": "Direct", "requested": "[4.1.4, )", @@ -15,23 +21,7 @@ "contentHash": "7gYo8ZR2eq3XkrilvUpLbTypeZy6IlD5FB8jah0YPhMOmDGhya4jJ3kfDMTTRt5m258Ou78P69mHMkG6DKZXsg==" }, "icsharpcode.decompiler": { - "type": "Project", - "dependencies": { - "System.Collections.Immutable": "[9.0.0, )", - "System.Reflection.Metadata": "[9.0.0, )" - } - }, - "System.Collections.Immutable": { - "type": "CentralTransitive", - "requested": "[10.0.1, )", - "resolved": "9.0.0", - "contentHash": "QhkXUl2gNrQtvPmtBTQHb0YsUrDiDQ2QS09YbtTTiSjGcf7NBqtYbrG/BE06zcBPCKEwQGzIv13IVdXNOSub2w==" - }, - "System.Reflection.Metadata": { - "type": "CentralTransitive", - "requested": "[10.0.1, )", - "resolved": "9.0.0", - "contentHash": "ANiqLu3DxW9kol/hMmTWbt3414t9ftdIuiIU7j80okq2YzAueo120M442xk1kDJWtmZTqWQn7wHDvMRipVOEOQ==" + "type": "Project" } } } diff --git a/ICSharpCode.Decompiler.Tests/.editorconfig b/ICSharpCode.Decompiler.Tests/.editorconfig new file mode 100644 index 000000000..26e2eb928 --- /dev/null +++ b/ICSharpCode.Decompiler.Tests/.editorconfig @@ -0,0 +1,11 @@ +# We disable some of the rules that don't make sense in our test +[*.cs] +dotnet_diagnostic.CA1060.severity = none +dotnet_diagnostic.CA1063.severity = none +dotnet_diagnostic.CA1065.severity = none +dotnet_diagnostic.CA1401.severity = none +dotnet_diagnostic.CA1821.severity = none +dotnet_diagnostic.CA2002.severity = none +dotnet_diagnostic.CA2101.severity = none +dotnet_diagnostic.CA2241.severity = none +dotnet_diagnostic.CA2263.severity = none # disable because it's choking on our test code in UndocumentedExpressions.cs diff --git a/ICSharpCode.Decompiler.Tests/Helpers/RoslynToolset.cs b/ICSharpCode.Decompiler.Tests/Helpers/RoslynToolset.cs index eba3254cd..0cf476717 100644 --- a/ICSharpCode.Decompiler.Tests/Helpers/RoslynToolset.cs +++ b/ICSharpCode.Decompiler.Tests/Helpers/RoslynToolset.cs @@ -36,6 +36,8 @@ using NUnit.Framework; namespace ICSharpCode.Decompiler.Tests.Helpers { + [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1001:Types that own disposable fields should be disposable", + Justification = "Derived types are intended to be used as static singletons, each living until the process terminates.")] abstract class AbstractToolset { readonly SourceCacheContext cache; diff --git a/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj b/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj index 83b84a146..5665d0222 100644 --- a/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj +++ b/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj @@ -147,6 +147,7 @@ + diff --git a/ICSharpCode.Decompiler.Tests/Properties/AssemblyInfo.cs b/ICSharpCode.Decompiler.Tests/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..ebab78e31 --- /dev/null +++ b/ICSharpCode.Decompiler.Tests/Properties/AssemblyInfo.cs @@ -0,0 +1,21 @@ +#region Using directives + +using System.Diagnostics.CodeAnalysis; +using System.Reflection; +using System.Runtime.InteropServices; + +#endregion + +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// This sets the default COM visibility of types in the assembly to invisible. +// If you need to expose a type to COM, use [ComVisible(true)] on that type. +[assembly: ComVisible(false)] + +[assembly: AssemblyVersion(DecompilerVersionInfo.Major + "." + DecompilerVersionInfo.Minor + "." + DecompilerVersionInfo.Build + "." + DecompilerVersionInfo.Revision)] +[assembly: AssemblyInformationalVersion(DecompilerVersionInfo.FullVersionWithCommitHash)] + +[assembly: SuppressMessage("Microsoft.Usage", "CA2243:AttributeStringLiteralsShouldParseCorrectly", + Justification = "AssemblyInformationalVersion does not need to be a parsable version")] + diff --git a/ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj b/ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj index 4066fee3f..cfec106fb 100644 --- a/ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj +++ b/ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj @@ -39,7 +39,6 @@ true true true - ICSharpCode.Decompiler.ruleset true @@ -90,6 +89,10 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive + + all + runtime; build; native; contentfiles; analyzers + @@ -686,7 +689,6 @@ - TextTemplatingFileGenerator diff --git a/ICSharpCode.Decompiler/ICSharpCode.Decompiler.ruleset b/ICSharpCode.Decompiler/ICSharpCode.Decompiler.ruleset deleted file mode 100644 index f833a3153..000000000 --- a/ICSharpCode.Decompiler/ICSharpCode.Decompiler.ruleset +++ /dev/null @@ -1,85 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/ICSharpCode.Decompiler/IL/Transforms/TransformCollectionAndObjectInitializers.cs b/ICSharpCode.Decompiler/IL/Transforms/TransformCollectionAndObjectInitializers.cs index 68c028776..944c5daf9 100644 --- a/ICSharpCode.Decompiler/IL/Transforms/TransformCollectionAndObjectInitializers.cs +++ b/ICSharpCode.Decompiler/IL/Transforms/TransformCollectionAndObjectInitializers.cs @@ -580,7 +580,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms public int GetHashCode(ILInstruction obj) { - throw new NotSupportedException(); + return obj.GetHashCode(); } } } diff --git a/ICSharpCode.Decompiler/packages.lock.json b/ICSharpCode.Decompiler/packages.lock.json index 2cce4eed7..1b8f05afc 100644 --- a/ICSharpCode.Decompiler/packages.lock.json +++ b/ICSharpCode.Decompiler/packages.lock.json @@ -2,6 +2,12 @@ "version": 1, "dependencies": { ".NETStandard,Version=v2.0": { + "Microsoft.CodeAnalysis.NetAnalyzers": { + "type": "Direct", + "requested": "[9.0.0, )", + "resolved": "9.0.0", + "contentHash": "JajbvkrBgtdRghavIjcJuNHMOja4lqBmEezbhZyqWPYh2cpLhT5mPpfC7NQVDO4IehWQum9t/nwF4v+qQGtYWg==" + }, "Microsoft.Sbom.Targets": { "type": "Direct", "requested": "[4.1.4, )", diff --git a/ICSharpCode.ILSpyCmd/packages.lock.json b/ICSharpCode.ILSpyCmd/packages.lock.json index 7d6168bf4..0e0e8bb66 100644 --- a/ICSharpCode.ILSpyCmd/packages.lock.json +++ b/ICSharpCode.ILSpyCmd/packages.lock.json @@ -13,6 +13,12 @@ "Microsoft.Extensions.Logging.Abstractions": "6.0.0" } }, + "Microsoft.CodeAnalysis.NetAnalyzers": { + "type": "Direct", + "requested": "[10.0.100, )", + "resolved": "10.0.100", + "contentHash": "uj9VuyvqylnNueJfU7u2PkI/hEMpZl8Wg9BXyI0eatNEldU5jDYPdwsM8aDL18+1oLovju25MiqOPaGRBnG72A==" + }, "Microsoft.Extensions.Hosting": { "type": "Direct", "requested": "[10.0.1, )", @@ -348,11 +354,7 @@ "contentHash": "yErfw/3pZkJE/VKza/Cm5idTpIKOy/vsmVi59Ta5SruPVtubzxb8CtnE8tyUpzs5pr0Y28GUFfSVzAhCLN3F/Q==" }, "icsharpcode.decompiler": { - "type": "Project", - "dependencies": { - "System.Collections.Immutable": "[9.0.0, )", - "System.Reflection.Metadata": "[9.0.0, )" - } + "type": "Project" }, "icsharpcode.ilspyx": { "type": "Project", @@ -360,9 +362,7 @@ "ICSharpCode.Decompiler": "[8.0.0-noversion, )", "K4os.Compression.LZ4": "[1.3.8, )", "Mono.Cecil": "[0.11.6, )", - "System.Composition.AttributedModel": "[10.0.1, )", - "System.Reflection.Metadata": "[10.0.1, )", - "System.Runtime.CompilerServices.Unsafe": "[6.1.2, )" + "System.Composition.AttributedModel": "[10.0.1, )" } }, "K4os.Compression.LZ4": { @@ -414,29 +414,11 @@ "resolved": "0.11.6", "contentHash": "f33RkDtZO8VlGXCtmQIviOtxgnUdym9xx/b1p9h91CRGOsJFxCFOFK1FDbVt1OCf1aWwYejUFa2MOQyFWTFjbA==" }, - "System.Collections.Immutable": { - "type": "CentralTransitive", - "requested": "[10.0.1, )", - "resolved": "9.0.0", - "contentHash": "QhkXUl2gNrQtvPmtBTQHb0YsUrDiDQ2QS09YbtTTiSjGcf7NBqtYbrG/BE06zcBPCKEwQGzIv13IVdXNOSub2w==" - }, "System.Composition.AttributedModel": { "type": "CentralTransitive", "requested": "[10.0.1, )", "resolved": "10.0.1", "contentHash": "mRxYvpCVPAeuLEk0c0kxWJVjbW1/HUoxCgYotOj9eDeQiYcTDOMdCQApsTrHYMN3pHBA8WoF00KGolG632Etaw==" - }, - "System.Reflection.Metadata": { - "type": "CentralTransitive", - "requested": "[10.0.1, )", - "resolved": "10.0.1", - "contentHash": "zpcfT/wacPPhE17zcudozlxQtWN/84qyiMyZNGLnK4cj2IMBtLsZYwYjVnALUhPliwyUVj/P7kaZvBWYBCnf2Q==" - }, - "System.Runtime.CompilerServices.Unsafe": { - "type": "CentralTransitive", - "requested": "[6.1.2, )", - "resolved": "6.1.2", - "contentHash": "2hBr6zdbIBTDE3EhK7NSVNdX58uTK6iHW/P/Axmm9sl1xoGSLqDvMtpecn226TNwHByFokYwJmt/aQQNlO5CRw==" } } } diff --git a/ICSharpCode.ILSpyX/packages.lock.json b/ICSharpCode.ILSpyX/packages.lock.json index 4dad6257b..97e1dc948 100644 --- a/ICSharpCode.ILSpyX/packages.lock.json +++ b/ICSharpCode.ILSpyX/packages.lock.json @@ -8,6 +8,12 @@ "resolved": "1.3.8", "contentHash": "LhwlPa7c1zs1OV2XadMtAWdImjLIsqFJPoRcIWAadSRn0Ri1DepK65UbWLPmt4riLqx2d40xjXRk0ogpqNtK7g==" }, + "Microsoft.CodeAnalysis.NetAnalyzers": { + "type": "Direct", + "requested": "[10.0.100, )", + "resolved": "10.0.100", + "contentHash": "uj9VuyvqylnNueJfU7u2PkI/hEMpZl8Wg9BXyI0eatNEldU5jDYPdwsM8aDL18+1oLovju25MiqOPaGRBnG72A==" + }, "Microsoft.Sbom.Targets": { "type": "Direct", "requested": "[4.1.4, )", @@ -65,17 +71,7 @@ "contentHash": "dk9JPxTCIevS75HyEQ0E4OVAFhB2N+V9ShCXf8Q6FkUQZDkgLI12y679Nym1YqsiSysuQskT7Z+6nUf3yab6Vw==" }, "icsharpcode.decompiler": { - "type": "Project", - "dependencies": { - "System.Collections.Immutable": "[9.0.0, )", - "System.Reflection.Metadata": "[9.0.0, )" - } - }, - "System.Collections.Immutable": { - "type": "CentralTransitive", - "requested": "[10.0.1, )", - "resolved": "9.0.0", - "contentHash": "QhkXUl2gNrQtvPmtBTQHb0YsUrDiDQ2QS09YbtTTiSjGcf7NBqtYbrG/BE06zcBPCKEwQGzIv13IVdXNOSub2w==" + "type": "Project" } } } diff --git a/ILSpy/ILSpy.csproj b/ILSpy/ILSpy.csproj index e35634311..c68fa5321 100644 --- a/ILSpy/ILSpy.csproj +++ b/ILSpy/ILSpy.csproj @@ -1,4 +1,4 @@ - + WinExe @@ -38,10 +38,6 @@ true - - ..\ICSharpCode.Decompiler\ICSharpCode.Decompiler.ruleset - -