Skip to content
Open
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
2 changes: 2 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ resources:
extends:
template: azure-pipelines/MicroBuild.1ES.Official.yml@MicroBuildTemplate
parameters:
settings:
networkIsolationPolicy: Permissive,CFSClean
sdl:
sourceAnalysisPool:
name: $(DncEngInternalBuildPool)
Expand Down
7 changes: 6 additions & 1 deletion test/Scaffolding/Shared/TemporaryFileProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@ namespace Microsoft.VisualStudio.Web.CodeGeneration
{
internal class TemporaryFileProvider : PhysicalFileProvider
{
public TemporaryFileProvider(string tmpPathRoot)
: base(Directory.CreateDirectory(Path.Combine(tmpPathRoot, "tmpFiles", Guid.NewGuid().ToString())).FullName)
{
}

public TemporaryFileProvider()
: base(Directory.CreateDirectory(Path.Combine(Path.GetTempPath(), "tmpfiles", Guid.NewGuid().ToString())).FullName)
: this(Path.GetTempPath())
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.CodeDom;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using Microsoft.Build.Tasks;
using Microsoft.DotNet.Scaffolding.Shared;
using Microsoft.VisualStudio.Web.CodeGeneration.Msbuild;
using Xunit;
Expand Down Expand Up @@ -80,7 +83,7 @@ public void TestProjectContextWithReferencedModel()
[Fact]
public void TestProjectContextNullableDisabled()
{
using (var fileProvider = new TemporaryFileProvider())
using (var fileProvider = new TemporaryFileProvider(GetCurrentAssemblyPath()))
{
new MsBuildProjectSetupHelper().SetupCodeGenerationProjectNullableDisabled(fileProvider, _outputHelper);
var path = Path.Combine(fileProvider.Root, MsBuildProjectStrings.RootProjectName2);
Expand All @@ -94,20 +97,20 @@ public void TestProjectContextNullableDisabled()
[Fact]
public void TestProjectContextNullableMissing()
{
using (var fileProvider = new TemporaryFileProvider())
using (var fileProvider = new TemporaryFileProvider(GetCurrentAssemblyPath()))
{
new MsBuildProjectSetupHelper().SetupCodeGenerationProjectNullableMissing(fileProvider, _outputHelper);
var path = Path.Combine(fileProvider.Root, MsBuildProjectStrings.RootProjectName3);

var projectContext = GetProjectContext(path, true);
Assert.Null(projectContext.Nullable);
Assert.Equal("enable", projectContext.Nullable);
}
}

[Fact]
public void TestProjectContextNullableEnabled()
{
using (var fileProvider = new TemporaryFileProvider())
using (var fileProvider = new TemporaryFileProvider(GetCurrentAssemblyPath()))
{
new MsBuildProjectSetupHelper().SetupCodeGenerationProjectNullableEnabled(fileProvider, _outputHelper);
var path = Path.Combine(fileProvider.Root, MsBuildProjectStrings.RootProjectName3);
Expand Down Expand Up @@ -171,5 +174,10 @@ public void GetXmlKeyValueTests()
Assert.Equal("", emptyValue, ignoreCase: true);
Assert.Equal("", nullValue, ignoreCase: true);
}

private static string GetCurrentAssemblyPath()
{
return Path.GetDirectoryName(typeof(ProjectContextWriterTests).GetType().Assembly.Location);
}
}
}
Loading