Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<Project>
<ItemGroup>
<PackageVersion Include="Basic.Reference.Assemblies.Net100" Version="1.8.9" />
<PackageVersion Include="coverlet.collector" Version="8.0.1" />
<PackageVersion Include="Fody" Version="6.6.4" />
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="10.0.6" />
Expand Down
1 change: 1 addition & 0 deletions tests/Generator.Tests/Generator.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<None Include="GenericMathTests.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Basic.Reference.Assemblies.Net100" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Condition="'$(TargetFramework)' != 'net472'" />
<PackageReference Include="PolySharp">
<PrivateAssets>all</PrivateAssets>
Expand Down
55 changes: 10 additions & 45 deletions tests/Generator.Tests/TestHelper.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using System.ComponentModel;
using System.Data.Common;
using System.Diagnostics;
using Basic.Reference.Assemblies;
using System.Text.RegularExpressions;
using System.Xml;
using Zomp.SyncMethodGenerator;
using static Generator.Tests.ModuleInitializer;

Expand Down Expand Up @@ -88,58 +85,26 @@ namespace Test;
var syntaxTree = CSharpSyntaxTree.ParseText(source, parseOptions);
var globalUsings = CSharpSyntaxTree.ParseText(GlobalUsingsSource, parseOptions);

// SyntaxTree syntaxTree = CSharpSyntaxTree.ParseText(source);
var linqAssembly = typeof(Enumerable).Assembly.Location;
var locations = new List<string>
{
typeof(IAsyncEnumerable<>).Assembly.Location,
typeof(DataReceivedEventHandler).Assembly.Location,
typeof(DbDataReader).Assembly.Location,
typeof(ValueTask<>).Assembly.Location,
typeof(System.Drawing.Point).Assembly.Location,
typeof(object).Assembly.Location,
typeof(Console).Assembly.Location,
typeof(Memory<>).Assembly.Location,
typeof(System.Buffers.MemoryPool<>).Assembly.Location,
typeof(Queue<>).Assembly.Location,
typeof(LinkedListNode<>).Assembly.Location,
typeof(XmlReader).Assembly.Location,
typeof(IQueryable).Assembly.Location,
typeof(System.Net.HttpStatusCode).Assembly.Location,
typeof(IListSource).Assembly.Location,
typeof(Regex).Assembly.Location,
typeof(Queryable).Assembly.Location,
#if NET8_0_OR_GREATER
typeof(AsyncEnumerable).Assembly.Location,
typeof(Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions).Assembly.Location,
#endif
linqAssembly,
};

var directory = Path.GetDirectoryName(linqAssembly);
var runtimeLocation = directory is null ? null : Path.Combine(directory, "System.Runtime.dll");
if (runtimeLocation is not null && File.Exists(runtimeLocation))
{
locations.Add(runtimeLocation);
}

var distinct = locations.Distinct().ToArray();

var references = distinct
.Select(l => MetadataReference.CreateFromFile(l));

List<SyntaxTree> syntaxTrees = [syntaxTree];

if (languageVersion >= LanguageVersion.CSharp10)
{
syntaxTrees.Add(globalUsings);
}

#if NET8_0_OR_GREATER
var assemblies = new[]
{
typeof(Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions).Assembly,
};
#else
IEnumerable<System.Reflection.Assembly> assemblies = [];
#endif
var compilation = CSharpCompilation.Create(
assemblyName: "Tests",
options: new(OutputKind.DynamicallyLinkedLibrary, nullableContextOptions: languageVersion >= LanguageVersion.CSharp8 ? NullableContextOptions.Enable : NullableContextOptions.Disable),
syntaxTrees: syntaxTrees,
references: references);
references: Net100.References.All.Concat(assemblies.Select(a => MetadataReference.CreateFromFile(a.Location))));

var generator = new SyncMethodSourceGenerator();

Expand Down
Loading