protected override byte[] GenerateCode(string inputFileName, string inputFileContent)
        {
            ProjectItem item = Dte.Solution.FindProjectItem(inputFileName);

            this.originalExt = Path.GetExtension(inputFileName);
            if (item != null)
            {
                // Sometimes "DtsPackage.Options"==null at this point. Make sure that options get loaded now.
                DtsPackage.EnsurePackageLoad();

                try
                {
                    string dts = GenerationService.ConvertToTypeScript(item);

                    Telemetry.TrackOperation("FileGenerated");

                    return(Encoding.UTF8.GetBytes(dts));
                }
                catch (Exception ex)
                {
                    Telemetry.TrackOperation("FileGenerated", Microsoft.VisualStudio.Telemetry.TelemetryResult.Failure);
                    Telemetry.TrackException("FileGenerated", ex);
                }
            }

            return(new byte[0]);
        }
        private void FileActionOccurred(object sender, TextDocumentFileActionEventArgs e)
        {
            if (e.FileActionType != FileActionTypes.ContentSavedToDisk)
            {
                return;
            }

            string fileName = Path.ChangeExtension(e.FilePath, ".d.ts");

            if (File.Exists(fileName))
            {
                DtsPackage.EnsurePackageLoad();
                CreateDtsFile(_item);
            }
        }
Exemplo n.º 3
0
        private void FileActionOccurred(object sender, TextDocumentFileActionEventArgs e)
        {
            if (e.FileActionType != FileActionTypes.ContentSavedToDisk)
            {
                return;
            }
            _item = VSHelpers.GetProjectItem(e.FilePath);
            Options.ReadOptionOverrides(_item, false);
            string fileName = Utility.GenerateFileName(e.FilePath);

            if (File.Exists(fileName))
            {
                DtsPackage.EnsurePackageLoad();
                CreateDtsFile(_item);
            }
        }