コード例 #1
0
ファイル: InstallBuilderFacts.cs プロジェクト: cemoses/aspnet
        public void NoCommandsIsNonApplicationPackage()
        {
            var project = ProjectUtilities.GetProject(@"{ }", @"foo", @"c:\foo\project.json");
            var builder = new InstallBuilder(project, null, null);

            Assert.False(builder.IsApplicationPackage);
        }
コード例 #2
0
ファイル: InstallBuilderFacts.cs プロジェクト: cemoses/aspnet
        public void ProjectWithCommandsIsApplicationPackage()
        {
            var project = ProjectUtilities.GetProject(@"{ ""commands"" : { ""demo"":""demo"" } }", @"foo", @"c:\foo\project.json");
            var builder = new InstallBuilder(project, null, null);

            Assert.True(builder.IsApplicationPackage);
        }
コード例 #3
0
        public void CompilerOptionsAreSetPerConfiguration()
        {
            var project = ProjectUtilities.GetProject(@"
{
    ""frameworks"" : {
        ""net45"":  {
            ""compilationOptions"": { ""allowUnsafe"": true, ""define"": [""X"", ""y""], ""platform"": ""x86"", ""warningsAsErrors"": true, ""optimize"": true, ""debugSymbols"": ""none"" }
        },
        ""k10"": {
            ""compilationOptions"": { ""warningsAsErrors"": true, ""debugSymbols"": ""pdbOnly"" }
        }
    }
}",
                                                      "foo",
                                                      @"c:\foo\project.json");

            var net45Options = project.GetCompilationSettings("net45");
            var k10Options   = project.GetCompilationSettings("k10");

            Assert.True(net45Options.CompilationOptions.AllowUnsafe);
            Assert.Equal(new[] { "DEBUG", "TRACE", "X", "y", "NET45" }, net45Options.Defines);
            Assert.Equal(Platform.X86, net45Options.CompilationOptions.Platform);
            Assert.Equal(ReportDiagnostic.Error, net45Options.CompilationOptions.GeneralDiagnosticOption);
            Assert.Equal(OptimizationLevel.Release, net45Options.CompilationOptions.OptimizationLevel);

            Assert.Equal(new[] { "DEBUG", "TRACE", "K10" }, k10Options.Defines);
            Assert.Equal(ReportDiagnostic.Error, k10Options.CompilationOptions.GeneralDiagnosticOption);
        }
コード例 #4
0
        /// <summary>
        /// Opens the in SharePoint designer.
        /// </summary>
        /// <param name="url">The URL.</param>
        void OpenInSharePointDesigner(string url)
        {
            string path = String.Empty;

            SharePointVersion version = ProjectUtilities.WhichSharePointVersionIsProjectDeployingTo();

            if (version == SharePointVersion.SP2010)
            {
                path = Path.Combine(ProjectUtilities.GetSharePoint14DesignerInstallRoot(),
                                    "SPDesign.exe");
            }
            else if (version == SharePointVersion.SP2013)
            {
                path = Path.Combine(ProjectUtilities.GetSharePoint15DesignerInstallRoot(),
                                    "SPDesign.exe");
            }

            ProcessUtilities utils = new ProcessUtilities();

            if (!String.IsNullOrEmpty(path))
            {
                if (File.Exists(path))
                {
                    utils.StartProcess(DTEManager.ActiveSharePointProject, path, url);
                }
            }
        }
コード例 #5
0
ファイル: ResourceResolverFacts.cs プロジェクト: yossidev/dnx
        public void ResolveNewNamedResxResources()
        {
            var expected = new[]
            {
                "testproject.OwnResources.resources",
                "testproject.subfolder.nestedresource.resources",
                "thisIs.New.Resource.resources"
            };
            var rootDir           = ProjectRootResolver.ResolveRootDirectory(Directory.GetCurrentDirectory());
            var testProjectFolder = Path.Combine(rootDir, "misc", "ResourcesTestProjects", "testproject");

            Project project = ProjectUtilities.GetProject(@"
{
    ""namedResource"": {
        ""thisIs.New.Resource"": ""../someresources/OtherResources.resx""
    }
}",
                                                          "testproject",
                                                          Path.Combine(testProjectFolder, "project.json"));

            var resolver          = new ResxResourceProvider();
            var embeddedResources = resolver.GetResources(project).Select(resource => resource.Name).ToArray();

            Assert.Equal(expected, embeddedResources);
        }
コード例 #6
0
ファイル: InstallBuilderFacts.cs プロジェクト: cemoses/aspnet
        public void BuildSucceedsForNonApplicationPackage()
        {
            var project = ProjectUtilities.GetProject(@"{ }", @"foo", @"c:\foo\project.json");
            var builder = new InstallBuilder(project, null, null);

            Assert.True(builder.Build(@"c:\foo"));
        }
コード例 #7
0
        /// <summary>
        /// Completes our initialization. This may be called from out overridden Initialize method and sometimes waiting until after the zombie state has
        /// gone from VS.
        /// </summary>
        private void InitializeMenus()
        {
            if (!this.SetupMode)
            {
                IServiceContainer sc = this;
                sc.AddService(typeof(IVsPackage), this, false);

                // Ensure that the IDE enviroment is available.
                EnvDTE.DTE dte = (EnvDTE.DTE) this.GetService(typeof(EnvDTE.DTE));
                if (dte == null)
                {
                    throw new InvalidOperationException(Strings.CouldNotGetVSEnvironment);
                }

                ProjectUtilities.Initialize(this);
                this.Core.Initialize(null, true);
                this.Helper.Initialize();

                // Ensuring that the form is created on the UI thread.
                if (InvisibleForm.Instance == null)
                {
                    throw new InvalidOperationException(Strings.NoInvisbleForm);
                }

                // Set up the menu items.
                this.commandSet = new PackageCommandSet(this);
                this.commandSet.Initialize();
            }
        }
コード例 #8
0
ファイル: ProjectFacts.cs プロジェクト: pgrudzien12/dnx
        public void ScriptsSetIsSet()
        {
            var projectContent = @"
{
    ""scripts"": {
        ""GroupA"": ""GroupA first command"",
        ""GroupB"": [
            ""GroupeB first command"",
            ""GroupeB second command"",
            ""GroupeB third command""
        ]
    }
}";
            var project        = ProjectUtilities.GetProject(projectContent, @"foo", @"C:\Foo\Project.json");

            Assert.NotNull(project.Scripts);
            Assert.Equal(2, project.Scripts.Count);

            var scriptGroupA = project.Scripts["GroupA"];

            Assert.Equal(1, scriptGroupA.Count());
            Assert.Equal("GroupA first command", scriptGroupA.First());

            var scriptGroupB = project.Scripts["GroupB"];

            Assert.Equal(3, scriptGroupB.Count());
            Assert.Equal("GroupeB first command", scriptGroupB.ElementAt(0));
            Assert.Equal("GroupeB second command", scriptGroupB.ElementAt(1));
            Assert.Equal("GroupeB third command", scriptGroupB.ElementAt(2));
        }
コード例 #9
0
        private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e)
        {
            try
            {
                var link = sender as System.Windows.Documents.Hyperlink;
                var type = link.DataContext as InformationType?;

                var fileName     = string.Empty;
                var lineNumber   = 0;
                var columnNumber = 0;

                var linkText = ((System.Windows.Documents.Run)link.Inlines.FirstInline).Text;
                var parser   = Factory.GetParser();
                switch (type)
                {
                case InformationType.File:
                    var    solution = ServiceProvider.GetService(typeof(SVsSolution)) as IVsSolution;
                    string solutionPath, solutionFile, suoFile;
                    solution.GetSolutionInfo(out solutionPath, out solutionFile, out suoFile);
                    if (string.IsNullOrEmpty(solutionPath))
                    {
                        return;
                    }
                    var tempString = solutionPath;
                    tempString = tempString.Remove(tempString.Length - 1);
                    tempString = tempString.Substring(tempString.LastIndexOf("\\") + 1, tempString.Length - tempString.LastIndexOf("\\") - 1);

                    var relationPath = linkText.Remove(0, linkText.LastIndexOf("\\" + tempString + "\\"));
                    relationPath = relationPath.Replace("\\" + tempString + "\\", string.Empty);

                    var lineNumberString = parser.GetLineNumberString(relationPath);
                    var startIndexPrefixLineNumberRelationPath = relationPath.LastIndexOf(lineNumberString);
                    relationPath = relationPath.Remove(startIndexPrefixLineNumberRelationPath, relationPath.Length - startIndexPrefixLineNumberRelationPath);     // delete line number text

                    fileName     = solutionPath + relationPath;
                    lineNumber   = parser.GetLineNumber(linkText);
                    columnNumber = 0;

                    NavigateTo(fileName, lineNumber, columnNumber);
                    break;

                case InformationType.Method:
                    linkText = linkText.Replace("at ", string.Empty);       // delete en prefix
                    linkText = linkText.Replace("в ", string.Empty);        // delete ru prefix
                    linkText = linkText.Remove(linkText.Length - 1);        // delete postfix

                    var projects = ProjectUtilities.GetProjectsOfCurrentSelections();
                    Factory.GetBackgroundScanner().StopIfRunning(blockUntilDone: true);

                    Factory.GetBackgroundScanner().Stopped += (source, arg) => NavigateTo(fileName, lineNumber, columnNumber);

                    Factory.GetBackgroundScanner().Start(projects, "FirstToolWindowPackage");

                    break;
                }
            }
            catch (Exception)
            {
            }
        }
コード例 #10
0
        /// <summary>
        /// Gets the containing project of the file (The IVsHierarchy) if available.
        /// </summary>
        /// <returns>The IVsHierarchyItem for the current document.</returns>
        private IVsHierarchy GetHierarchyItem()
        {
            var solution = this.serviceProvider.GetService(typeof(SVsSolution)) as IVsSolution;

            if (solution == null || this.Document == null)
            {
                return(null);
            }

            var project = ProjectUtilities.GetProject(this.Document);

            if (project == null)
            {
                return(null);
            }

            IVsHierarchy hierarchyItem;
            var          result = solution.GetProjectOfUniqueName(project.UniqueName, out hierarchyItem);

            if (result == VSConstants.S_OK)
            {
                return(hierarchyItem);
            }

            return(null);
        }
コード例 #11
0
ファイル: ProjectFacts.cs プロジェクト: pgrudzien12/dnx
        public void CompilerServicesIsNullByDefault()
        {
            var projectContent = @"{}";
            var project        = ProjectUtilities.GetProject(projectContent, @"foo", @"C:\Foo\Project.json");

            Assert.Null(project.CompilerServices);
        }
コード例 #12
0
ファイル: ProjectFacts.cs プロジェクト: pgrudzien12/dnx
        public void AuthorsAreSet()
        {
            var project = ProjectUtilities.GetProject(@"{ ""authors"": [""Bob"", ""Dean""] }", @"foo", @"C:\Foo\Project.json");

            Assert.Equal("Bob", project.Authors[0]);
            Assert.Equal("Dean", project.Authors[1]);
        }
コード例 #13
0
    // Update is called once per frame
    void Update()
    {
        {
            Ray        ray = new Ray();
            RaycastHit hit;
            ray.direction = gameObject.transform.forward;
            ray.origin    = gameObject.transform.position;



            if (Physics.Raycast(ray, out hit))
            {
                Debug.DrawLine(transform.position, hit.point, Color.red);

                if (hit.collider.gameObject.name == "Restart" && OVRInput.GetDown(OVRInput.Button.One))
                {
                    ProjectUtilities.restart();
                }
                else if (hit.collider.gameObject.name == "Exit" && OVRInput.GetDown(OVRInput.Button.One))
                {
                    ProjectUtilities.exitGame();
                }
            }
        }
    }
コード例 #14
0
ファイル: ProjectFacts.cs プロジェクト: pgrudzien12/dnx
        public void OwnersAreSet()
        {
            var project = ProjectUtilities.GetProject(@"{ ""owners"": [""Alice"", ""Chi""] }", @"foo", @"C:\Foo\Project.json");

            Assert.Equal("Alice", project.Owners[0]);
            Assert.Equal("Chi", project.Owners[1]);
        }
コード例 #15
0
ファイル: ProjectFacts.cs プロジェクト: pgrudzien12/dnx
        public void EmptyTagsListWhenNotSpecified()
        {
            var project = ProjectUtilities.GetProject(@" { }", "foo", @"c:\foo\project.json");

            Assert.NotNull(project.Tags);
            Assert.Equal(0, project.Tags.Count());
        }
コード例 #16
0
ファイル: ProjectFacts.cs プロジェクト: pgrudzien12/dnx
        public void CommonBooleanPropertiesAreSet(string jsonPropertyName,
                                                  string jsonPropertyValue,
                                                  string objectPropertyName,
                                                  bool expectResult)
        {
            var propertyInfo = typeof(Project).GetTypeInfo().GetDeclaredProperty(objectPropertyName);

            Assert.NotNull(propertyInfo);

            string projectContent;

            if (jsonPropertyValue != null)
            {
                projectContent = string.Format("{{ \"{0}\": {1} }}", jsonPropertyName, jsonPropertyValue);
            }
            else
            {
                projectContent = @"{}";
            }

            var project = ProjectUtilities.GetProject(projectContent, @"foo", @"C:\Foo\Project.json");

            var propertyValue = (bool)propertyInfo.GetValue(project);

            Assert.Equal(expectResult, propertyValue);
        }
コード例 #17
0
ファイル: ProjectFacts.cs プロジェクト: pgrudzien12/dnx
        public void NameIsIgnoredIsSpecified()
        {
            // Arrange & Act
            var project = ProjectUtilities.GetProject(@"{ ""name"": ""hello"" }", @"foo", @"c:\foo\project.json");

            // Assert
            Assert.Equal("foo", project.Name);
        }
コード例 #18
0
ファイル: ProjectFacts.cs プロジェクト: pgrudzien12/dnx
        public void ScriptsSetIsEmptyByDefault()
        {
            var projectContent = @"{}";
            var project        = ProjectUtilities.GetProject(projectContent, @"foo", @"C:\Foo\Project.json");

            Assert.NotNull(project.Scripts);
            Assert.Equal(0, project.Scripts.Count);
        }
コード例 #19
0
        protected override ProjectFilesCollection CreateFilesCollection(string jsonContent, string projectDir)
        {
            var project = ProjectUtilities.GetProject(
                jsonContent,
                "testproject",
                Path.Combine(Root.DirPath, PathHelper.NormalizeSeparator(projectDir), "project.json"));

            return(project.Files);
        }
コード例 #20
0
        /// <summary>
        /// Initializes a new instance of the BuildIntegrationOptions class.
        /// </summary>
        /// <param name="project">The MSBuild project.</param>
        public BuildIntegrationOptions(Project project)
        {
            Param.RequireNotNull(project, "project");

            this.project = project;
            this.setting = ProjectUtilities.GetBuildIntegrationInProject(this.project);

            this.InitializeComponent();
        }
コード例 #21
0
ファイル: ProjectFacts.cs プロジェクト: pgrudzien12/dnx
        public void CompilerServicesDefaultValues()
        {
            var projectContent = @"{""compiler"": {} }";
            var project        = ProjectUtilities.GetProject(projectContent, @"foo", @"C:\Foo\Project.json");

            Assert.NotNull(project.CompilerServices);
            Assert.Equal("C#", project.CompilerServices.Name);
            Assert.Null(project.CompilerServices.ProjectCompiler.AssemblyName);
            Assert.Null(project.CompilerServices.ProjectCompiler.TypeName);
        }
コード例 #22
0
ファイル: PackageCommandSet.cs プロジェクト: kubiix/StyleCop
        /// <summary>
        /// Fired when status must be determined for the menu item "Exclude Item" on a single project item.
        /// </summary>
        /// <param name="sender">The <c>OleMenuCommand</c> that represents the menu item.</param>
        /// <param name="eventArgs">The event arguments.</param>
        private void StatusExcludeSingleProjectItem(object sender, EventArgs eventArgs)
        {
            Param.AssertNotNull(sender, "sender");
            Param.Ignore(eventArgs);

            bool show = ProjectUtilities.IsItemIncluded(this.helper, AnalysisType.Item);

            OleMenuCommand menuCommand = (OleMenuCommand)sender;

            this.StatusAnalyzeBase(menuCommand, show);
        }
コード例 #23
0
        /// <summary>
        /// Fired when status must be determined for the menu item "Include" on the context menu of the code editor.
        /// </summary>
        /// <param name="sender">The <c>OleMenuCommand</c> that represents the menu item.</param>
        /// <param name="eventArgs">The event arguments.</param>
        private void StatusIncludeThisFile(object sender, EventArgs eventArgs)
        {
            Param.AssertNotNull(sender, "sender");
            Param.Ignore(eventArgs);

            bool show = ProjectUtilities.IsItemIncluded(AnalysisType.File);

            OleMenuCommand menuCommand = (OleMenuCommand)sender;

            this.StatusAnalyzeBase(menuCommand, !show);
        }
コード例 #24
0
        /// <summary>
        /// Fired when status must be determined for the menu item "Global Settings".
        /// </summary>
        /// <param name="sender">The <c>OleMenuCommand</c> that represents the menu item.</param>
        /// <param name="eventArgs">The event arguments.</param>
        private void StatusProjectSettings(object sender, EventArgs eventArgs)
        {
            Param.AssertNotNull(sender, "sender");
            Param.Ignore(eventArgs);

            bool show = ProjectUtilities.SupportsStyleCop(this.helper, AnalysisType.Project);

            OleMenuCommand menuCommand = (OleMenuCommand)sender;

            this.StatusAnalyzeBase(menuCommand, show);
        }
コード例 #25
0
        public static async Task OpenDataCsvApp(DebugEvaluationResult result)
        {
            if (Interlocked.Exchange(ref _busy, 1) > 0)
            {
                return;
            }

            var workflowProvider = VsAppShell.Current.ExportProvider.GetExportedValue <IRInteractiveWorkflowProvider>();
            var workflow         = workflowProvider.GetOrCreate();
            var session          = workflow.RSession;

            var folder = GetTempCsvFilesFolder();

            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }

            var variableName = result.Name ?? _variableNameReplacement;
            var csvFileName  = MakeCsvFileName(variableName);
            var file         = ProjectUtilities.GetUniqueFileName(folder, csvFileName, "csv", appendUnderscore: true);
            var rfile        = file.Replace('\\', '/');

            string currentStatusText = string.Empty;
            await VsAppShell.Current.DispatchOnMainThreadAsync(() => {
                var statusBar = VsAppShell.Current.GetGlobalService <IVsStatusbar>(typeof(SVsStatusbar));
                statusBar.GetText(out currentStatusText);
            });

            try {
                await SetStatusTextAsync(Resources.Status_WritingCSV);

                using (var e = await session.BeginEvaluationAsync()) {
                    await e.EvaluateAsync($"write.csv({result.Expression}, file='{rfile}')", REvaluationKind.Normal);
                }

                if (File.Exists(file))
                {
                    Task.Run(() => {
                        try {
                            Process.Start(file);
                        } catch (Win32Exception ex) {
                            ShowErrorMessage(ex.Message);
                        } catch (FileNotFoundException ex) {
                            ShowErrorMessage(ex.Message);
                        }
                    }).DoNotWait();
                }
            } finally {
                await SetStatusTextAsync(currentStatusText);
            }

            Interlocked.Exchange(ref _busy, 0);
        }
コード例 #26
0
ファイル: ProjectFacts.cs プロジェクト: pgrudzien12/dnx
        public void ProjectUrlIsSet()
        {
            var project = ProjectUtilities.GetProject(@"
{
    ""projectUrl"": ""https://github.com/aspnet/KRuntime""
}",
                                                      "foo",
                                                      @"c:\foo\project.json");

            Assert.Equal("https://github.com/aspnet/KRuntime", project.ProjectUrl);
        }
コード例 #27
0
        /// <summary>
        /// Is the token replacement file.
        /// </summary>
        /// <param name="project">The SharePoint project to get the token replacement values for.</param>
        /// <param name="fileName">The file name.</param>
        /// <returns>True if its valid for token replacment.</returns>
        public static bool IsTokenReplacementFile(ISharePointProject project,
                                                  string fileName)
        {
            List <string> fileExtensionsForTokenisation = ProjectUtilities.GetTokenReplacementFileExtension(project.ProjectService.Convert <ISharePointProject, EnvDTE.Project>(project));

            string ext = Path.GetExtension(fileName).ToLower();

            ext = ext.Replace(".", "");

            return(fileExtensionsForTokenisation.Contains(ext));
        }
コード例 #28
0
        /// <summary>
        /// Handles the Click event of the copyAssemblyNameItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Microsoft.VisualStudio.SharePoint.MenuItemEventArgs"/> instance containing the event data.</param>
        void copyAssemblyNameItem_Click(object sender, MenuItemEventArgs e)
        {
            ISharePointProject project = e.Owner as ISharePointProject;

            EnvDTE.Project dteProject = DTEManager.ProjectService.Convert <ISharePointProject, EnvDTE.Project>(project);

            if (dteProject.DTE.Solution.SolutionBuild.BuildState != vsBuildState.vsBuildStateInProgress)
            {
                dteProject.DTE.Solution.SolutionBuild.BuildProject(dteProject.DTE.Solution.SolutionBuild.ActiveConfiguration.Name, dteProject.UniqueName, true);
                Clipboard.SetText(ProjectUtilities.GetAssemblyName(project));
            }
        }
コード例 #29
0
ファイル: ProjectFacts.cs プロジェクト: pgrudzien12/dnx
        public void CompilerOptionsAreNotNullIfNotSpecified()
        {
            var project = ProjectUtilities.GetProject(@"
{}",
                                                      "foo",
                                                      @"c:\foo\project.json");

            var compilerOptions = project.GetCompilerOptions();

            Assert.NotNull(compilerOptions);
            Assert.Null(compilerOptions.Defines);
        }
コード例 #30
0
ファイル: ProjectFacts.cs プロジェクト: pgrudzien12/dnx
        public void CompilerOptionsAreSetPerConfiguration()
        {
            var project = ProjectUtilities.GetProject(@"
{
    ""frameworks"" : {
        ""net45"":  {
            ""compilationOptions"": { ""allowUnsafe"": true, ""define"": [""X"", ""y""], ""platform"": ""x86"", ""warningsAsErrors"": true }
        },
        ""dnx451"": {
        },
        ""dnxcore50"": {
            ""compilationOptions"": { ""define"": [""X""], ""warningsAsErrors"": true }
        },
        ""k10"": {
            ""compilationOptions"": { ""warningsAsErrors"": true }
        }
    }
}",
                                                      "foo",
                                                      @"c:\foo\project.json");

            var compilerOptions = project.GetCompilerOptions();

            Assert.NotNull(compilerOptions);
            var net45Options = project.GetCompilerOptions(FrameworkNameHelper.ParseFrameworkName("net45"));

            Assert.NotNull(net45Options);
            Assert.True(net45Options.AllowUnsafe.Value);
            Assert.Equal(new[] { "X", "y", "NET45" }, net45Options.Defines);
            Assert.True(net45Options.WarningsAsErrors.Value);
            Assert.Equal("x86", net45Options.Platform);

            var dnx451Options = project.GetCompilerOptions(FrameworkNameHelper.ParseFrameworkName("dnx451"));

            Assert.NotNull(dnx451Options);
            Assert.Equal(new[] { "DNX451" }, dnx451Options.Defines);
            Assert.Null(dnx451Options.AllowUnsafe);

            var aspnetCore50Options = project.GetCompilerOptions(FrameworkNameHelper.ParseFrameworkName("dnxcore50"));

            Assert.NotNull(aspnetCore50Options);
            Assert.Equal(new[] { "X", "DNXCORE50" }, aspnetCore50Options.Defines);
            Assert.True(aspnetCore50Options.WarningsAsErrors.Value);

            var k10Options = project.GetCompilerOptions(FrameworkNameHelper.ParseFrameworkName("k10"));

            Assert.NotNull(k10Options);
            Assert.Null(k10Options.AllowUnsafe);
            Assert.Equal(new[] { "K10" }, k10Options.Defines);
            Assert.True(k10Options.WarningsAsErrors.Value);
            Assert.Null(k10Options.Platform);
        }