Skip to content

Commit be1179b

Browse files
committed
Fix build
1 parent 548a06d commit be1179b

61 files changed

Lines changed: 658 additions & 771 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,16 @@
11
namespace PropertyChangedAnalyzers.Benchmarks.Benchmarks
22
{
3-
using System;
4-
using System.Collections.Generic;
5-
using System.Collections.Immutable;
63
using System.IO;
7-
using System.Linq;
8-
using System.Net;
9-
104
using Gu.Roslyn.Asserts;
115

126
using Microsoft.CodeAnalysis;
13-
using Microsoft.CodeAnalysis.CSharp;
14-
using Microsoft.CodeAnalysis.Diagnostics;
157

168
public static class Code
179
{
18-
private static readonly IReadOnlyList<MetadataReference> MetadataReferences = new[]
19-
{
20-
MetadataReference.CreateFromFile(typeof(object).Assembly.Location).WithAliases(ImmutableArray.Create("global", "corlib")),
21-
MetadataReference.CreateFromFile(typeof(System.Diagnostics.Debug).Assembly.Location).WithAliases(ImmutableArray.Create("global", "system")),
22-
MetadataReference.CreateFromFile(typeof(Enumerable).Assembly.Location),
23-
MetadataReference.CreateFromFile(typeof(WebClient).Assembly.Location),
24-
MetadataReference.CreateFromFile(typeof(System.Xml.Serialization.XmlSerializer).Assembly.Location),
25-
MetadataReference.CreateFromFile(typeof(CSharpCompilation).Assembly.Location),
26-
MetadataReference.CreateFromFile(typeof(Compilation).Assembly.Location),
27-
};
28-
29-
private static readonly IReadOnlyList<DiagnosticAnalyzer> AllAnalyzers =
30-
typeof(KnownSymbol)
31-
.Assembly
32-
.GetTypes()
33-
.Where(t => typeof(DiagnosticAnalyzer).IsAssignableFrom(t) && !t.IsAbstract)
34-
.Select(t => (DiagnosticAnalyzer)Activator.CreateInstance(t))
35-
.ToArray();
36-
3710
public static string ProjectDirectory { get; } = ProjectFile.Find("PropertyChangedAnalyzers.Benchmarks.csproj").DirectoryName;
3811

3912
public static string BenchmarksDirectory { get; } = Path.Combine(ProjectDirectory, "Benchmarks");
4013

41-
public static Solution ValidCodeProject { get; } = CodeFactory.CreateSolution(
42-
ProjectFile.Find("ValidCode.csproj"),
43-
AllAnalyzers,
44-
MetadataReferences);
14+
public static Solution ValidCodeProject { get; } = CodeFactory.CreateSolution(ProjectFile.Find("ValidCode.csproj"));
4515
}
4616
}

PropertyChangedAnalyzers.Benchmarks/Benchmarks/Codegen/CodeGen.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
1-
namespace PropertyChangedAnalyzers.Benchmarks.Benchmarks
1+
namespace PropertyChangedAnalyzers.Benchmarks.Benchmarks
22
{
33
using System;
44
using System.Collections.Generic;
55
using System.IO;
66
using System.Linq;
77
using System.Text;
8+
89
using Gu.Roslyn.Asserts;
10+
911
using Microsoft.CodeAnalysis.Diagnostics;
12+
1013
using NUnit.Framework;
1114

1215
[Explicit("Script")]
1316
public class CodeGen
1417
{
15-
private static IReadOnlyList<DiagnosticAnalyzer> AllAnalyzers { get; } = typeof(KnownSymbol).Assembly
16-
.GetTypes()
17-
.Where(typeof(DiagnosticAnalyzer).IsAssignableFrom)
18-
.Select(t => (DiagnosticAnalyzer)Activator.CreateInstance(t))
19-
.ToArray();
18+
private static IReadOnlyList<DiagnosticAnalyzer> AllAnalyzers { get; } =
19+
typeof(KnownSymbol)
20+
.Assembly
21+
.GetTypes()
22+
.Where(t => typeof(DiagnosticAnalyzer).IsAssignableFrom(t) && !t.IsAbstract)
23+
.Select(t => (DiagnosticAnalyzer)Activator.CreateInstance(t))
24+
.ToArray();
2025

2126
[TestCaseSource(nameof(AllAnalyzers))]
2227
public void AnalyzersBenchmark(DiagnosticAnalyzer analyzer)
Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,3 @@
11
using System;
2-
using Gu.Roslyn.Asserts;
32

43
[assembly: CLSCompliant(false)]
5-
6-
[assembly: MetadataReference(typeof(object), new[] { "global", "mscorlib" })]
7-
[assembly: MetadataReference(typeof(System.Diagnostics.Debug), new[] { "global", "System" })]
8-
[assembly: TransitiveMetadataReferences(typeof(Gu.Roslyn.CodeFixExtensions.DocumentEditorAction))]
9-
[assembly: MetadataReferences(
10-
typeof(System.Linq.Enumerable),
11-
typeof(System.Net.WebClient),
12-
typeof(System.Drawing.Bitmap),
13-
typeof(System.Data.Common.DbConnection),
14-
typeof(System.Xml.Serialization.XmlSerializer),
15-
typeof(System.Runtime.Serialization.DataContractSerializer),
16-
typeof(System.Windows.Media.Brush),
17-
typeof(System.Windows.Controls.Control),
18-
typeof(System.Windows.Media.Matrix),
19-
typeof(System.Xaml.XamlLanguage),
20-
typeof(Gu.Reactive.ICondition),
21-
typeof(Gu.Wpf.Reactive.AsyncCommand),
22-
typeof(NUnit.Framework.Assert))]

PropertyChangedAnalyzers.Test/HandlesRecursion.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public static void NotEmpty()
2626
}
2727

2828
[TestCaseSource(nameof(AllAnalyzers))]
29-
public static async Task InTrySet(DiagnosticAnalyzer analyzer)
29+
public static void InTrySet(DiagnosticAnalyzer analyzer)
3030
{
3131
var viewModelBase = @"
3232
namespace N.Core
@@ -66,11 +66,11 @@ public int P2
6666
}
6767
}
6868
}";
69-
await Analyze.GetDiagnosticsAsync(analyzer, new[] { viewModelBase, code }, MetadataReferences.FromAttributes()).ConfigureAwait(false);
69+
_ = Analyze.GetDiagnostics(analyzer, new[] { viewModelBase, code });
7070
}
7171

7272
[TestCaseSource(nameof(AllAnalyzers))]
73-
public static async Task InOnPropertyChanged(DiagnosticAnalyzer analyzer)
73+
public static void InOnPropertyChanged(DiagnosticAnalyzer analyzer)
7474
{
7575
var viewModelBaseCode = @"
7676
namespace N.Core
@@ -118,11 +118,11 @@ public int P2
118118
}
119119
}
120120
}";
121-
await Analyze.GetDiagnosticsAsync(analyzer, new[] { viewModelBaseCode, code }, MetadataReferences.FromAttributes()).ConfigureAwait(false);
121+
_ = Analyze.GetDiagnostics(analyzer, new[] { viewModelBaseCode, code });
122122
}
123123

124124
[TestCaseSource(nameof(AllAnalyzers))]
125-
public static async Task InProperty(DiagnosticAnalyzer analyzer)
125+
public static void InProperty(DiagnosticAnalyzer analyzer)
126126
{
127127
var fooCode = @"
128128
namespace N
@@ -267,7 +267,7 @@ protected virtual void OnPropertyChanged([CallerMemberName] string propertyName
267267
}
268268
}
269269
}";
270-
await Analyze.GetDiagnosticsAsync(analyzer, new[] { fooCode }, MetadataReferences.FromAttributes()).ConfigureAwait(false);
270+
_ = Analyze.GetDiagnostics(analyzer, new[] { fooCode });
271271
}
272272

273273
[TestCaseSource(nameof(AllAnalyzers))]
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
namespace PropertyChangedAnalyzers.Test.Helpers
2+
{
3+
using System.IO;
4+
using System.Reflection;
5+
using Gu.Roslyn.AnalyzerExtensions;
6+
using Gu.Roslyn.Asserts;
7+
8+
public static class LibrarySettings
9+
{
10+
private static readonly DirectoryInfo ProjectDirectory = ProjectFile.Find("PropertyChangedAnalyzers.Test.csproj").Directory;
11+
12+
internal static Settings CaliburnMicro { get; } = Settings.Default.WithMetadataReferences(MetadataReferences.Transitive(typeof(Caliburn.Micro.PropertyChangedBase)));
13+
14+
internal static Settings Stylet { get; } = Settings.Default.WithMetadataReferences(MetadataReferences.Transitive(LoadUnsigned("Stylet.dll")));
15+
16+
internal static Settings MvvmLight { get; } = Settings.Default.WithMetadataReferences(MetadataReferences.Transitive(typeof(GalaSoft.MvvmLight.ViewModelBase)));
17+
18+
internal static Settings MvvmCross { get; } = Settings.Default.WithMetadataReferences(MetadataReferences.Transitive(LoadUnsigned("MvvmCross.dll")));
19+
20+
internal static Settings Prism { get; } = Settings.Default.WithMetadataReferences(MetadataReferences.Transitive(typeof(Microsoft.Practices.Prism.Mvvm.BindableBase)));
21+
22+
// Use this if the dll is not signed
23+
private static Assembly LoadUnsigned(string dllName)
24+
{
25+
if (ProjectDirectory.EnumerateFiles(dllName, SearchOption.AllDirectories)
26+
.TryFirst(out var dll))
27+
{
28+
return Assembly.LoadFile(dll.FullName);
29+
}
30+
31+
throw new FileNotFoundException(dllName);
32+
}
33+
}
34+
}

PropertyChangedAnalyzers.Test/Helpers/OnPropertyChangedTests.Find.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ protected virtual void OnPropertyChanged([CallerMemberName] string propertyName
2929
}
3030
}
3131
}");
32-
var compilation = CSharpCompilation.Create("test", new[] { syntaxTree }, MetadataReferences.FromAttributes());
32+
var compilation = CSharpCompilation.Create("test", new[] { syntaxTree }, Settings.Default.MetadataReferences);
3333
var semanticModel = compilation.GetSemanticModel(syntaxTree);
3434
var classDeclaration = syntaxTree.FindClassDeclaration("C");
3535
var type = semanticModel.GetDeclaredSymbol(classDeclaration);
@@ -57,7 +57,7 @@ protected virtual void OnPropertyChanged([CallerMemberName] string propertyName
5757
}
5858
}
5959
}");
60-
var compilation = CSharpCompilation.Create("test", new[] { syntaxTree }, MetadataReferences.FromAttributes());
60+
var compilation = CSharpCompilation.Create("test", new[] { syntaxTree }, Settings.Default.MetadataReferences);
6161
var semanticModel = compilation.GetSemanticModel(syntaxTree);
6262
var classDeclaration = syntaxTree.FindClassDeclaration("C");
6363
var type = semanticModel.GetDeclaredSymbol(classDeclaration);
@@ -91,7 +91,7 @@ protected virtual void OnPropertyChanged([CallerMemberName] string propertyName
9191
}
9292
}
9393
}");
94-
var compilation = CSharpCompilation.Create("test", new[] { syntaxTree }, MetadataReferences.FromAttributes());
94+
var compilation = CSharpCompilation.Create("test", new[] { syntaxTree }, Settings.Default.MetadataReferences);
9595
var semanticModel = compilation.GetSemanticModel(syntaxTree);
9696
var classDeclaration = syntaxTree.FindClassDeclaration("C");
9797
var type = semanticModel.GetDeclaredSymbol(classDeclaration);
@@ -125,7 +125,7 @@ protected virtual void OnPropertyChanged([CallerMemberName] string propertyName
125125
}
126126
}
127127
}");
128-
var compilation = CSharpCompilation.Create("test", new[] { syntaxTree }, MetadataReferences.FromAttributes());
128+
var compilation = CSharpCompilation.Create("test", new[] { syntaxTree }, Settings.Default.MetadataReferences);
129129
var semanticModel = compilation.GetSemanticModel(syntaxTree);
130130
var classDeclaration = syntaxTree.FindClassDeclaration("C");
131131
var type = semanticModel.GetDeclaredSymbol(classDeclaration);
@@ -163,7 +163,7 @@ public class C : N.ViewModelBase
163163
}
164164
}");
165165

166-
var compilation = CSharpCompilation.Create("test", new[] { viewModelBaseCode, code }, MetadataReferences.FromAttributes());
166+
var compilation = CSharpCompilation.Create("test", new[] { viewModelBaseCode, code }, Settings.Default.MetadataReferences);
167167
var semanticModel = compilation.GetSemanticModel(code);
168168
var classDeclaration = code.FindClassDeclaration("ViewModel");
169169
var type = semanticModel.GetDeclaredSymbol(classDeclaration);
@@ -201,7 +201,7 @@ public class C : N.ViewModelBase
201201
}
202202
}");
203203

204-
var compilation = CSharpCompilation.Create("test", new[] { viewModelBaseCode, code }, MetadataReferences.FromAttributes());
204+
var compilation = CSharpCompilation.Create("test", new[] { viewModelBaseCode, code }, Settings.Default.MetadataReferences);
205205
var semanticModel = compilation.GetSemanticModel(code);
206206
var classDeclaration = code.FindClassDeclaration("ViewModel");
207207
var type = semanticModel.GetDeclaredSymbol(classDeclaration);
@@ -250,7 +250,7 @@ protected virtual void OnPropertyChanged([CallerMemberName] string propertyName
250250
}
251251
}");
252252

253-
var compilation = CSharpCompilation.Create("test", new[] { syntaxTree }, MetadataReferences.FromAttributes());
253+
var compilation = CSharpCompilation.Create("test", new[] { syntaxTree }, Settings.Default.MetadataReferences);
254254
var semanticModel = compilation.GetSemanticModel(syntaxTree);
255255
var classDeclaration = syntaxTree.FindClassDeclaration("C");
256256
var type = semanticModel.GetDeclaredSymbol(classDeclaration);
@@ -277,7 +277,7 @@ private static void OnPropertyChanged([CallerMemberName] string propertyName = n
277277
}
278278
}
279279
}");
280-
var compilation = CSharpCompilation.Create("test", new[] { syntaxTree }, MetadataReferences.FromAttributes());
280+
var compilation = CSharpCompilation.Create("test", new[] { syntaxTree }, Settings.Default.MetadataReferences);
281281
var semanticModel = compilation.GetSemanticModel(syntaxTree);
282282
var classDeclaration = syntaxTree.FindClassDeclaration("C");
283283
var type = semanticModel.GetDeclaredSymbol(classDeclaration);
@@ -311,7 +311,7 @@ protected virtual void OnPropertyChanged([CallerMemberName] string propertyName
311311
}
312312
}
313313
}");
314-
var compilation = CSharpCompilation.Create("test", new[] { syntaxTree }, MetadataReferences.FromAttributes());
314+
var compilation = CSharpCompilation.Create("test", new[] { syntaxTree }, Settings.Default.MetadataReferences);
315315
var semanticModel = compilation.GetSemanticModel(syntaxTree);
316316
var classDeclaration = syntaxTree.FindClassDeclaration("C");
317317
var type = semanticModel.GetDeclaredSymbol(classDeclaration);
@@ -342,7 +342,7 @@ protected virtual void OnPropertyChanged([CallerMemberName] string propertyName
342342
}
343343
}
344344
}".AssertReplace("propertyName ?? string.Empty", expression));
345-
var compilation = CSharpCompilation.Create("test", new[] { syntaxTree }, MetadataReferences.FromAttributes());
345+
var compilation = CSharpCompilation.Create("test", new[] { syntaxTree }, Settings.Default.MetadataReferences);
346346
var semanticModel = compilation.GetSemanticModel(syntaxTree);
347347
var classDeclaration = syntaxTree.FindClassDeclaration("C");
348348
var type = semanticModel.GetDeclaredSymbol(classDeclaration);
@@ -374,7 +374,7 @@ protected virtual void OnPropertyChanged([CallerMemberName] string propertyName
374374
}
375375
}
376376
}".AssertReplace("propertyName ?? string.Empty", expression));
377-
var compilation = CSharpCompilation.Create("test", new[] { syntaxTree }, MetadataReferences.FromAttributes());
377+
var compilation = CSharpCompilation.Create("test", new[] { syntaxTree }, Settings.Default.MetadataReferences);
378378
var semanticModel = compilation.GetSemanticModel(syntaxTree);
379379
var classDeclaration = syntaxTree.FindClassDeclaration("C");
380380
var type = semanticModel.GetDeclaredSymbol(classDeclaration);

0 commit comments

Comments
 (0)