public void ProcessTests(ProjectComponents components, ProjectOutputType outputType, string startingTfmString, string expectedTfmString, bool tryUpdate) { // Arrange var fixture = new Fixture(); using var mock = AutoMock.GetLoose(); var tfm = ParseTfm(startingTfmString); var expectedTfm = ParseTfm(expectedTfmString); var project = new Mock <IProject>(); project.Setup(p => p.OutputType).Returns(outputType); var state = new Mock <ITargetFrameworkSelectorFilterState>(); state.Setup(s => s.Current).Returns(tfm); state.Setup(s => s.Project).Returns(project.Object); state.Setup(s => s.Components).Returns(components); var filter = mock.Create <WindowsSdkTargetFrameworkSelectorFilter>(); // Act filter.Process(state.Object); // Assert var count = tryUpdate ? Times.Once() : Times.Never(); state.Verify(s => s.TryUpdate(expectedTfm), count); }
private static string AdjustTargetTFM(ProjectStyle projectStyle, ProjectOutputType outputType, string candidateTargetTFM) { if (candidateTargetTFM.ContainsIgnoreCase(MSBuildFacts.Net5) && projectStyle is ProjectStyle.WindowsDesktop) { return(MSBuildFacts.Net5Windows); } if (projectStyle is not ProjectStyle.MSTest && projectStyle is not ProjectStyle.Web && outputType is ProjectOutputType.Library) { return(MSBuildFacts.NetStandard20); } //conditional checks for Xamarin Project Styles if (projectStyle is ProjectStyle.XamarinDroid) { return(XamarinFacts.Net6XamarinAndroid); } if (projectStyle is ProjectStyle.XamariniOS) { return(XamarinFacts.Net6XamariniOS); } return(candidateTargetTFM); }
public void ProcessTests(ProjectOutputType outputType, bool tryUpdate) { // Arrange var fixture = new Fixture(); using var mock = AutoMock.GetLoose(); var project = new Mock <IProject>(); project.Setup(p => p.OutputType).Returns(outputType); var tfm = fixture.Create <TargetFrameworkMoniker>(); var state = new Mock <ITargetFrameworkSelectorFilterState>(); state.Setup(s => s.Project).Returns(project.Object); state.Setup(s => s.AppBase).Returns(tfm); var filter = mock.Create <ExecutableTargetFrameworkSelectorFilter>(); // Act filter.Process(state.Object); // Assert var count = tryUpdate ? Times.Once() : Times.Never(); state.Verify(s => s.TryUpdate(tfm), count); }
public BaselineProject(UnconfiguredProject project, ImmutableArray <string> globalProperties, ProjectStyle projectStyle, ProjectOutputType outputType) : this() { GlobalProperties = globalProperties; Project = project ?? throw new ArgumentNullException(nameof(project)); ProjectStyle = projectStyle; OutputType = outputType; }
public BaselineProject(UnconfiguredProject project, ImmutableArray <string> globalProperties, ProjectStyle projectStyle, ProjectOutputType outputType, string candidateTargetTFM, bool keepCurrentTFMs) : this() { GlobalProperties = globalProperties; Project = project ?? throw new ArgumentNullException(nameof(project)); ProjectStyle = projectStyle; OutputType = outputType; TargetTFM = keepCurrentTFMs ? GetCurrentTFM(globalProperties, project) : AdjustTargetTFM(projectStyle, outputType, candidateTargetTFM); }
public ProjectPropertiesConfiguration CreateFromDocument(XDocument document) { var configurationElement = document.Descendants().First(f => f.Name.LocalName == ProjectConfigConstants.ConfigurationTagName).Parent; var rootNamespace = _xmlParsingService.TryParsingSubElementStringValue(configurationElement, ProjectConfigConstants.RootNamespaceLocalName); var assemblyName = _xmlParsingService.TryParsingSubElementStringValue(configurationElement, ProjectConfigConstants.AssemblyNameLocalName); var outputTypeString = _xmlParsingService.TryParsingSubElementStringValue(configurationElement, ProjectConfigConstants.OutputTypeLocalName); var outputType = ProjectOutputType.Parse(outputTypeString); var result = new ProjectPropertiesConfiguration(rootNamespace, assemblyName, outputType); return(result); }
private static string AdjustTargetTFM(ProjectStyle projectStyle, ProjectOutputType outputType, string candidateTargetTFM) { if (candidateTargetTFM.ContainsIgnoreCase(MSBuildFacts.Net5) && projectStyle is ProjectStyle.WindowsDesktop) { return(MSBuildFacts.Net5Windows); } if (projectStyle is not ProjectStyle.MSTest && outputType is ProjectOutputType.Library) { return(MSBuildFacts.NetStandard20); } return(candidateTargetTFM); }
public override string GetTypeCommand(ProjectOutputType outputType, IIntermediateCompilerOptions options) { switch (outputType) { case ProjectOutputType.ClassLibrary: return(OutputClassLibrary); case ProjectOutputType.ConsoleApplication: return(OutputConsoleApp); case ProjectOutputType.Module: return(OutputModule); case ProjectOutputType.WindowsApplication: return(OutputWindowsApp); } return(string.Empty); }
private static string GetOutputTypeExtension(ProjectOutputType outputType) { switch (outputType) { case ProjectOutputType.Exe: case ProjectOutputType.Winexe: return "exe"; case ProjectOutputType.Library: case ProjectOutputType.Module: return "dll"; } return ""; }
public abstract string GetTypeCommand(ProjectOutputType outputType, IIntermediateCompilerOptions options);