using System; using System.Collections.Generic; using System.Collections.Immutable; using System.Diagnostics; using System.Linq; using System.Linq.Expressions; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Threading; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Text; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")] [assembly: AssemblyCompany("Valheim.ServersideQoL.CodeAnalysis")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+d2c324ae03da43f3657ad33447faf467152a1eb9")] [assembly: AssemblyProduct("Valheim.ServersideQoL.CodeAnalysis")] [assembly: AssemblyTitle("Valheim.ServersideQoL.CodeAnalysis")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Valheim.ServersideQoL.CodeAnalysis { [DiagnosticAnalyzer("C#", new string[] { })] public sealed class ExpressionCacheAnalyzer : DiagnosticAnalyzer { public const string DiagnosticId = "ARG0001"; private static readonly DiagnosticDescriptor Rule = new DiagnosticDescriptor("ARG0001", "Caller line not unique", "Each call to this method must be on its own line", "Usage", (DiagnosticSeverity)3, true, (string)null, (string)null, Array.Empty()); public override ImmutableArray SupportedDiagnostics { get; } = ImmutableCollectionsMarshal.AsImmutableArray((DiagnosticDescriptor[])(object)new DiagnosticDescriptor[1] { Rule }); public override void Initialize(AnalysisContext context) { context.EnableConcurrentExecution(); context.ConfigureGeneratedCodeAnalysis((GeneratedCodeAnalysisFlags)0); context.RegisterSyntaxNodeAction((Action)delegate(SyntaxNodeAnalysisContext context) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) MethodDeclarationSyntax val = (MethodDeclarationSyntax)((SyntaxNodeAnalysisContext)(ref context)).Node; HashSet<(ISymbol, int)> hashSet = null; foreach (InvocationExpressionSyntax item in ((SyntaxNode)val).DescendantNodes((Func)null, false).OfType()) { SymbolInfo symbolInfo = CSharpExtensions.GetSymbolInfo(((SyntaxNodeAnalysisContext)(ref context)).SemanticModel, (ExpressionSyntax)(object)item, default(CancellationToken)); ISymbol symbol = ((SymbolInfo)(ref symbolInfo)).Symbol; if (symbol != null && symbol.GetAttributes().Any(delegate(AttributeData x) { INamedTypeSymbol attributeClass = x.AttributeClass; return ((attributeClass != null) ? ((ISymbol)attributeClass).Name : null) == "MustBeOnUniqueLineAttribute"; })) { Location location = ((CSharpSyntaxNode)item).GetLocation(); FileLinePositionSpan lineSpan = location.GetLineSpan(); HashSet<(ISymbol, int)> obj = hashSet ?? (hashSet = new HashSet<(ISymbol, int)>()); LinePosition endLinePosition = ((FileLinePositionSpan)(ref lineSpan)).EndLinePosition; if (!obj.Add((symbol, ((LinePosition)(ref endLinePosition)).Line))) { ((SyntaxNodeAnalysisContext)(ref context)).ReportDiagnostic(Diagnostic.Create(Rule, location, Array.Empty())); } } } }, (SyntaxKind[])(object)new SyntaxKind[1] { (SyntaxKind)8875 }); } } [AttributeUsage(AttributeTargets.Method)] public sealed class MustBeOnUniqueLineAttribute : Attribute { } [DiagnosticAnalyzer("C#", new string[] { })] public sealed class ExpressionFactoryAnalyzer : DiagnosticAnalyzer { public const string DiagnosticId = "ARG0002"; private static readonly DiagnosticDescriptor Rule = new DiagnosticDescriptor("ARG0002", "Expression factories must be static", "Expression factories must be static", "Usage", (DiagnosticSeverity)3, true, (string)null, (string)null, Array.Empty()); private static readonly string __expressionTypeStartsWith = typeof(Expression).FullName + "<"; public override ImmutableArray SupportedDiagnostics { get; } = ImmutableCollectionsMarshal.AsImmutableArray((DiagnosticDescriptor[])(object)new DiagnosticDescriptor[1] { Rule }); public override void Initialize(AnalysisContext context) { context.EnableConcurrentExecution(); context.ConfigureGeneratedCodeAnalysis((GeneratedCodeAnalysisFlags)0); context.RegisterSyntaxNodeAction((Action)delegate(SyntaxNodeAnalysisContext context) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) ParenthesizedLambdaExpressionSyntax val = (ParenthesizedLambdaExpressionSyntax)((SyntaxNodeAnalysisContext)(ref context)).Node; CSharpSyntaxNode body = ((AnonymousFunctionExpressionSyntax)val).Body; SimpleLambdaExpressionSyntax val2 = (SimpleLambdaExpressionSyntax)(object)((body is SimpleLambdaExpressionSyntax) ? body : null); if (val2 != null) { SymbolInfo symbolInfo = CSharpExtensions.GetSymbolInfo(((SyntaxNodeAnalysisContext)(ref context)).SemanticModel, (ExpressionSyntax)(object)val, default(CancellationToken)); ISymbol symbol = ((SymbolInfo)(ref symbolInfo)).Symbol; IMethodSymbol val3 = (IMethodSymbol)(object)((symbol is IMethodSymbol) ? symbol : null); if (val3 != null && !symbol.IsStatic && ((ISymbol)val3.ReturnType).ToDisplayString((SymbolDisplayFormat)null).StartsWith(__expressionTypeStartsWith)) { ((SyntaxNodeAnalysisContext)(ref context)).ReportDiagnostic(Diagnostic.Create(Rule, ((CSharpSyntaxNode)val).GetLocation(), Array.Empty())); } } }, (SyntaxKind[])(object)new SyntaxKind[1] { (SyntaxKind)8643 }); } } }