Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed Oct 24, 2024
1 parent a9f3316 commit b52e23e
Show file tree
Hide file tree
Showing 15 changed files with 64 additions and 20 deletions.
12 changes: 12 additions & 0 deletions src/ApiBuilderTests/ApiBuilderTests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" />
<PackageReference Include="NUnit" />
<PackageReference Include="NUnit3TestAdapter" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="ProjectDefaults" PrivateAssets="all" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#if NET9_0 && DEBUG
using Microsoft.CodeAnalysis.CSharp;

[TestFixture]
class BuildApiTest
{
Expand Down Expand Up @@ -46,7 +43,7 @@ public void RunWithRoslyn()

count += types.Count(_ => _.Key.EndsWith("Attribute"));

WriteHelper(types, nameof(EnumPolyfill), writer, ref count);
WriteHelper(types, "EnumPolyfill", writer, ref count);
WriteHelper(types, "RegexPolyfill", writer, ref count);
WriteHelper(types, "StringPolyfill", writer, ref count);
WriteHelper(types, "BytePolyfill", writer, ref count);
Expand Down Expand Up @@ -530,6 +527,4 @@ static BuildApiTest() =>
]
}
];
}

#endif
}
5 changes: 5 additions & 0 deletions src/ApiBuilderTests/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
global using NUnit.Framework;
global using System;
global using System.Diagnostics.CodeAnalysis;
global using Microsoft.CodeAnalysis.CSharp;
global using Microsoft.CodeAnalysis.CSharp.Syntax;
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#if NET9_0 && DEBUG
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis;

public static class RoslynExtensions
{
Expand Down Expand Up @@ -48,5 +46,4 @@ public static IEnumerable<AttributeSyntax> Attributes(this ParameterSyntax metho

public static string Value(this AttributeArgumentSyntax argument) =>
argument.Expression.ToString();
}
#endif
}
File renamed without changes.
34 changes: 34 additions & 0 deletions src/ApiBuilderTests/SolutionDirectoryFinder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
static class SolutionDirectoryFinder
{
public static string Find([CallerFilePath] string sourceFile = "")
{
if (TryFind(sourceFile, out var solutionDirectory))
{
return solutionDirectory;
}

throw new("Could not find solution directory");
}

public static bool TryFind(string sourceFile, [NotNullWhen(true)] out string? path)
{
var currentDirectory = Directory.GetParent(sourceFile)!.FullName;
do
{
if (Directory.GetFiles(currentDirectory, "*.sln").Length > 0)
{
path = currentDirectory;
return true;
}

var parent = Directory.GetParent(currentDirectory);
if (parent == null)
{
path = null;
return false;
}

currentDirectory = parent.FullName;
} while (true);
}
}
1 change: 0 additions & 1 deletion src/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<PackageVersion Include="NUnit" Version="3.14.0" />
<PackageVersion Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageVersion Include="ProjectDefaults" Version="1.0.139" />
<PackageVersion Include="SimpleInfoName" Version="2.3.0" />
<PackageVersion Include="System.Memory" Version="4.5.5" />
<PackageVersion Include="System.Net.Http" Version="4.3.4" />
<PackageVersion Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
Expand Down
2 changes: 0 additions & 2 deletions src/NoRefsTests/NoRefsTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
</PropertyGroup>
<ItemGroup>
<Compile Include="..\Tests\*.cs" />
<Compile Remove="..\Tests\BuildApiTest.cs" />
<Compile Remove="..\Tests\CollectionBuilderAttributeTests.cs" />
<Compile Remove="..\Tests\NullabilitySync.cs" />
<Compile Remove="..\Tests\IndexRangeSample.cs" />
<Compile Remove="..\Tests\NamedTupleSample.cs" />
<Compile Remove="..\Tests\RangeIndexUsage.cs" />
Expand Down
6 changes: 6 additions & 0 deletions src/Polyfill.sln
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsumeCsLatestMajor", "Con
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsumeCsDefault", "ConsumeCsDefault\ConsumeCsDefault.csproj", "{86AA1F8D-4081-4D31-812E-866C0951415D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ApiBuilderTests", "ApiBuilderTests\ApiBuilderTests.csproj", "{CC0C08FE-14E1-4A3D-8547-EFC8097D48C4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -126,6 +128,10 @@ Global
{86AA1F8D-4081-4D31-812E-866C0951415D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{86AA1F8D-4081-4D31-812E-866C0951415D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{86AA1F8D-4081-4D31-812E-866C0951415D}.Release|Any CPU.Build.0 = Release|Any CPU
{CC0C08FE-14E1-4A3D-8547-EFC8097D48C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CC0C08FE-14E1-4A3D-8547-EFC8097D48C4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CC0C08FE-14E1-4A3D-8547-EFC8097D48C4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CC0C08FE-14E1-4A3D-8547-EFC8097D48C4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
1 change: 1 addition & 0 deletions src/Polyfill.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"solution": {
"path": "Polyfill.sln",
"projects": [
"ApiBuilderTests\\ApiBuilderTests.csproj",
"Consume\\Consume.csproj",
"Polyfill\\Polyfill.csproj",
"TargetFrameworkUsage\\TargetFrameworkUsage.csproj",
Expand Down
2 changes: 1 addition & 1 deletion src/PublicTests/PublicTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<PolyPublic>true</PolyPublic>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\Tests\*.cs" Exclude="..\Tests\BuildApiTest.cs;..\Tests\NullabilitySync.cs" />
<Compile Include="..\Tests\*.cs" />
<PackageReference Include="NUnit" />
<PackageReference Include="NUnit3TestAdapter" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
Expand Down
1 change: 0 additions & 1 deletion src/Tests/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
global using NUnit.Framework;
global using System;
global using System.Diagnostics.CodeAnalysis;
global using Microsoft.CodeAnalysis.CSharp.Syntax;
2 changes: 0 additions & 2 deletions src/Tests/Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@
<TargetFrameworks>$(TargetFrameworks);netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" />
<PackageReference Include="NUnit" />
<PackageReference Include="NUnit3TestAdapter" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="MarkdownSnippets.MsBuild" PrivateAssets="all" />
<PackageReference Include="ProjectDefaults" PrivateAssets="all" />
<PackageReference Include="SimpleInfoName" />
<PackageReference Include="System.Memory" Condition="$(TargetFrameworkIdentifier) == '.NETStandard' or $(TargetFrameworkIdentifier) == '.NETFramework' or $(TargetFramework.StartsWith('netcoreapp3'))" />
<PackageReference Include="System.ValueTuple" Condition="$(TargetFramework.StartsWith('net46'))" />
<PackageReference Include="System.Net.Http" Condition="$(TargetFramework.StartsWith('net4'))" />
Expand Down
2 changes: 1 addition & 1 deletion src/UnsafeTests/UnsafeTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\Tests\*.cs" Exclude="..\Tests\BuildApiTest.cs;..\Tests\NullabilitySync.cs" />
<Compile Include="..\Tests\*.cs" />
<PackageReference Include="NUnit" />
<PackageReference Include="NUnit3TestAdapter" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
Expand Down

0 comments on commit b52e23e

Please sign in to comment.