public void Digi001CodeFix() { var testCode = @" namespace RoslynSandBox { using DigiBotExtensions; [IrcConnection("""")] public class ↓MuhConnection { } }"; var fixedCode = @" namespace RoslynSandBox { using DigiBotExtensions; [IrcConnection("""")] public class MuhConnection : IIrcConnection { } }"; AnalyzerAssert.AddTransitiveMetadataReferences(typeof(DigiBotExtension.IIrcConnection).Assembly); AnalyzerAssert.AddTransitiveMetadataReferences(typeof(Avalonia.Controls.Control).Assembly); AnalyzerAssert.AddTransitiveMetadataReferences(typeof(DIGI001IrcConnectShouldImplementIIrcConnection).Assembly); AnalyzerAssert.CodeFix(Analyzer, CodeFix, testCode, fixedCode, allowCompilationErrors: AllowCompilationErrors.No); AnalyzerAssert.ResetMetadataReferences(); }
public void Digi001NotFound() { var testCode = @" namespace RosylnSandbox { class MuhClass {} }"; AnalyzerAssert.AddTransitiveMetadataReferences(typeof(DIGI001IrcConnectShouldImplementIIrcConnection).Assembly); AnalyzerAssert.Valid(Analyzer, testCode); AnalyzerAssert.ResetMetadataReferences(); }
public void SubclassBindableBase() { var testCode = @" namespace RoslynSandbox { public class Foo : Microsoft.Practices.Prism.Mvvm.BindableBase { public int Bar { get; set; } } }"; AnalyzerAssert.AddTransitiveMetadataReferences(typeof(Microsoft.Practices.Prism.Mvvm.BindableBase).Assembly); AnalyzerAssert.Valid(Analyzer, testCode); }
public void Digi001Valid() { var testCode = @" namespace RosylnSandbox { using System; using System.Collections.Generic; using System.Collections.Concurrent; using System.IO; using System.Linq; using System.Net.Sockets; using System.Threading.Tasks; using System.Threading; using DigiBotExtension; using Avalonia.Controls; [IrcConnection("""")] public class ValidClass : IIrcConnection { public int RetryLimit { get; set; } public Action<StreamWriter,IEnumerable<string>> Pong { get; set; } public Action<StreamWriter> Logon { get; set; } public Avalonia.Controls.Control ConfigBox { get; } public event MessageReceived OnMessageReceived; public event ConnectedEvent OnConnected; public event DisconnectEvent OnDisconnect; public string Channel { get; set; } public bool Connected { get; } public Task Start(){ return Task.CompletedTask; } public Task Stop(){ return Task.CompletedTask; } public void WriteLine(object o){} public void WriteLine(string format, params object[] o){} public void Dispose(){} } }"; AnalyzerAssert.AddTransitiveMetadataReferences(typeof(DigiBotExtension.IIrcConnection).Assembly); AnalyzerAssert.AddTransitiveMetadataReferences(typeof(Avalonia.Controls.Control).Assembly); AnalyzerAssert.AddTransitiveMetadataReferences(typeof(DIGI001IrcConnectShouldImplementIIrcConnection).Assembly); AnalyzerAssert.Valid(Analyzer, testCode); AnalyzerAssert.ResetMetadataReferences(); }
public void Digi001Found() { var testCode = @" namespace RoslynSandBox { using DigiBotExtension; [IrcConnection("""")] public class ↓MuhConnection { } }"; AnalyzerAssert.AddTransitiveMetadataReferences(typeof(DigiBotExtension.IIrcConnection).Assembly); AnalyzerAssert.AddTransitiveMetadataReferences(typeof(Avalonia.Controls.Control).Assembly); AnalyzerAssert.AddTransitiveMetadataReferences(typeof(DIGI001IrcConnectShouldImplementIIrcConnection).Assembly); var expectedMessage = ExpectedDiagnostic.CreateFromCodeWithErrorsIndicated( "DIGI001", "The class MuhConnection should impliment: IIrcConnection to use IrcConnectionAttribute.", testCode, out testCode); AnalyzerAssert.Diagnostics <DIGI001IrcConnectShouldImplementIIrcConnection>(expectedMessage, testCode); AnalyzerAssert.ResetMetadataReferences(); }
public void OneTimeSetUp() { AnalyzerAssert.AddTransitiveMetadataReferences(typeof(Caliburn.Micro.PropertyChangedBase).Assembly); }
public void OneTimeSetUp() { AnalyzerAssert.AddTransitiveMetadataReferences(typeof(Microsoft.Practices.Prism.Mvvm.BindableBase).Assembly); }
public void OneTimeSetUp() { AnalyzerAssert.AddTransitiveMetadataReferences(typeof(GalaSoft.MvvmLight.ViewModelBase).Assembly); }
public void OneTimeSetUp() { AnalyzerAssert.AddTransitiveMetadataReferences(typeof(Caliburn.Micro.Screen).Assembly); }
public void AddTransitiveMetadataReferences() { AnalyzerAssert.MetadataReferences.Clear(); AnalyzerAssert.AddTransitiveMetadataReferences(typeof(CSharpCompilationOptions).Assembly); #if NET461 var expected = new[] { "Accessibility.dll", "Microsoft.Build.Framework.dll", "Microsoft.Build.Tasks.v4.0.dll", "Microsoft.Build.Utilities.v4.0.dll", "Microsoft.CodeAnalysis.CSharp.dll", "Microsoft.CodeAnalysis.dll", "mscorlib.dll", "netstandard.dll", "SMDiagnostics.dll", "System.Collections.Concurrent.dll", "System.Collections.dll", "System.Collections.Immutable.dll", "System.ComponentModel.Composition.dll", "System.ComponentModel.DataAnnotations.dll", "System.Configuration.dll", "System.Configuration.Install.dll", "System.Core.dll", "System.Data.Common.dll", "System.Data.dll", "System.Data.OracleClient.dll", "System.Data.SqlXml.dll", "System.Deployment.dll", "System.Design.dll", "System.Diagnostics.Debug.dll", "System.Diagnostics.StackTrace.dll", "System.Diagnostics.Tools.dll", "System.Diagnostics.Tracing.dll", "System.DirectoryServices.dll", "System.DirectoryServices.Protocols.dll", "System.dll", "System.Drawing.Design.dll", "System.Drawing.dll", "System.EnterpriseServices.dll", "System.Globalization.dll", "System.Globalization.Extensions.dll", "System.IO.Compression.dll", "System.IO.Compression.FileSystem.dll", "System.IO.dll", "System.IO.FileSystem.dll", "System.IO.FileSystem.Primitives.dll", "System.Linq.dll", "System.Linq.Expressions.dll", "System.Net.Http.dll", "System.Net.Sockets.dll", "System.Numerics.dll", "System.Reflection.dll", "System.Reflection.Extensions.dll", "System.Reflection.Metadata.dll", "System.Reflection.Primitives.dll", "System.Resources.ResourceManager.dll", "System.Runtime.Caching.dll", "System.Runtime.dll", "System.Runtime.Extensions.dll", "System.Runtime.InteropServices.dll", "System.Runtime.InteropServices.RuntimeInformation.dll", "System.Runtime.Numerics.dll", "System.Runtime.Remoting.dll", "System.Runtime.Serialization.dll", "System.Runtime.Serialization.Formatters.Soap.dll", "System.Runtime.Serialization.Primitives.dll", "System.Runtime.Serialization.Xml.dll", "System.Security.Cryptography.Algorithms.dll", "System.Security.Cryptography.Primitives.dll", "System.Security.dll", "System.Security.SecureString.dll", "System.ServiceModel.Internals.dll", "System.ServiceProcess.dll", "System.Text.Encoding.CodePages.dll", "System.Text.Encoding.dll", "System.Text.Encoding.Extensions.dll", "System.Threading.dll", "System.Threading.Overlapped.dll", "System.Threading.Tasks.dll", "System.Threading.Tasks.Parallel.dll", "System.Transactions.dll", "System.ValueTuple.dll", "System.Web.ApplicationServices.dll", "System.Web.dll", "System.Web.RegularExpressions.dll", "System.Web.Services.dll", "System.Windows.Forms.dll", "System.Xaml.dll", "System.Xml.dll", "System.Xml.Linq.dll", "System.Xml.ReaderWriter.dll", "System.Xml.XDocument.dll", "System.Xml.XPath.XDocument.dll", }; #else var expected = new[] { "Microsoft.CodeAnalysis.CSharp.dll", "System.Runtime.dll", "System.Private.CoreLib.dll", "System.Private.Uri.dll", "Microsoft.CodeAnalysis.dll", "System.Diagnostics.Debug.dll", "System.Collections.dll", "System.Collections.Immutable.dll", "System.Resources.ResourceManager.dll", "System.Diagnostics.Tools.dll", "System.Linq.dll", "System.Runtime.Extensions.dll", "System.Security.Principal.dll", "System.Threading.dll", "System.Threading.Tasks.dll", "System.IO.dll", "System.Text.Encoding.dll", "System.Reflection.Metadata.dll", "System.Runtime.InteropServices.dll", "System.IO.Compression.dll", "System.Buffers.dll", "System.IO.MemoryMappedFiles.dll", "System.IO.FileSystem.dll", "System.Threading.Overlapped.dll", "System.Text.Encoding.Extensions.dll", "System.Reflection.dll", "System.Security.Cryptography.Algorithms.dll", "System.Security.Cryptography.Encoding.dll", "System.Security.Cryptography.Primitives.dll", "System.Collections.Concurrent.dll", "System.Diagnostics.Tracing.dll", "System.Globalization.dll", "System.Xml.XDocument.dll", "System.Private.Xml.Linq.dll", "System.Private.Xml.dll", "System.Diagnostics.TraceSource.dll", "System.Collections.NonGeneric.dll", "System.Collections.Specialized.dll", "System.Text.RegularExpressions.dll", "System.Net.Primitives.dll", "Microsoft.Win32.Primitives.dll", "System.Net.Requests.dll", "System.Net.WebHeaderCollection.dll", "System.Net.Http.dll", "System.Security.Cryptography.X509Certificates.dll", "System.Security.Cryptography.Cng.dll", "System.Runtime.Numerics.dll", "System.Security.Cryptography.Csp.dll", "System.Threading.Thread.dll", "System.Diagnostics.DiagnosticSource.dll", "System.Net.ServicePoint.dll", "System.Net.Security.dll", "System.Security.Principal.Windows.dll", "System.Security.Claims.dll", "System.Threading.ThreadPool.dll", "System.Net.Sockets.dll", "System.Net.NameResolution.dll", "System.Threading.Tasks.Extensions.dll", "System.Reflection.Emit.dll", "System.Reflection.Emit.ILGeneration.dll", "System.Reflection.Primitives.dll", "System.Reflection.Emit.Lightweight.dll", "System.ObjectModel.dll", "System.Console.dll", "System.ValueTuple.dll", "System.IO.FileSystem.Primitives.dll", "System.Xml.ReaderWriter.dll", "System.Xml.XPath.XDocument.dll", "System.Reflection.Extensions.dll", "System.Text.Encoding.CodePages.dll", "System.Linq.Expressions.dll", "System.Threading.Tasks.Parallel.dll", }; #endif var actual = AnalyzerAssert.MetadataReferences .Select(x => Path.GetFileName(x.Display)) .OrderBy(x => x) .ToArray(); Dump(actual); CollectionAssert.AreEqual(expected, actual); }