Beispiel #1
0
        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);
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
 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);
 }
Beispiel #6
0
        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);
        }
Beispiel #7
0
        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);
        }
Beispiel #8
0
        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);
        }
Beispiel #9
0
        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 "";
        }
Beispiel #10
0
 public abstract string GetTypeCommand(ProjectOutputType outputType, IIntermediateCompilerOptions options);