Skip to content

Commit c1af333

Browse files
committed
Fix random csproj generation
1 parent 6036bb1 commit c1af333

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

test/Azure.Functions.Sdk.Tests/Integration/MSBuildSdkTestBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ protected virtual void Dispose(bool disposing)
5454
}
5555

5656
// Ensure this starts with a non-numeric character to be a valid csproj name.
57-
protected string GetTempCsproj() => "azfunc.test." + _temp.GetRandomFile(ext: ".csproj");
57+
protected string GetTempCsproj() => _temp.GetRandomCsproj();
5858

5959
private static string GetArtifactsPath()
6060
{

test/Azure.Functions.Sdk.Tests/Tasks/Extensions/ResolveExtensionPackagesTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ private static ResolveExtensionPackages CreateTask(
156156
private string RestoreProject(Action<ProjectCreator>? configure = null)
157157
{
158158
ProjectCreator project = ProjectCreator.Templates.NetCoreProject(
159-
path: _temp.GetRandomFile(ext: ".csproj"), targetFramework: "net8.0", configure: configure);
159+
path: _temp.GetRandomCsproj(), targetFramework: "net8.0", configure: configure);
160160

161161
project.Restore().Should().BeSuccessful(); // use assertion to throw on failure.
162162
project.TryGetPropertyValue("ProjectAssetsFile", out string? value);

test/Azure.Functions.Sdk.Tests/TempDirectory.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ public TempDirectory()
1515

1616
public string Path { get; }
1717

18+
public string GetRandomCsproj()
19+
{
20+
// This will become RootNamespace. Ensure it is a valid root namespace. GetRandomFileName()
21+
// can return invalid namespaces.
22+
string name = "azfunc.test_" + IOPath.GetRandomFileName().Replace('.', '_') + ".csproj";
23+
return IOPath.Combine(Path, name);
24+
}
25+
1826
public string GetRandomFile(string? ext = null)
1927
{
2028
string path = IOPath.Combine(Path, IOPath.GetRandomFileName());

0 commit comments

Comments
 (0)