private static List <string> GetReferences(IEnumerable <IntellisenseObject> objects, ProjectItem sourceItem) { if (Options.KeepReferencesUnchanged) { ProjectItem generatedProjectItem = sourceItem.ProjectItems .Cast <ProjectItem>() .Where(item => GenerationService.GenerateFileName(sourceItem.Name) == item.Name) .FirstOrDefault(); if (generatedProjectItem != null) { string documentText = VSHelpers.GetDocumentText(generatedProjectItem); if (string.IsNullOrWhiteSpace(documentText) == false) { string pattern = "/// <reference path=\"(.*)\" />\r\n"; return(new Regex(pattern).Matches(documentText) .Cast <Match>() .Select(m => m.Groups[1].Value) .OrderBy(r => r) .ToList()); } } } return(objects .SelectMany(o => o.References) .Where(r => Path.GetFileName(r) != GenerationService.GenerateFileName(sourceItem.Name)) .Distinct() .OrderBy(r => r) .ToList()); }
internal static DefinitionMapData GetDefinitionMapData(ProjectItem projectItem) { // Initialize our result DefinitionMapData result = null; // Try to find our map data for the typescript definition file ProjectItem definitionMapProjectItem = projectItem.ProjectItems .Cast <ProjectItem>() .Where(pi => pi.Name == GenerationService.GenerateFileName(projectItem.Name) + ".map") .FirstOrDefault(); // Continue if found if (definitionMapProjectItem != null) { // Get the text of our mapping file string documentText = VSHelpers.GetDocumentText(definitionMapProjectItem); // Continue if the document has text if (string.IsNullOrWhiteSpace(documentText) == false) { // Try to parse the containing json string // When a SerializationException is getting thrown the document text wasn't valid try { result = JsonConvert.DeserializeObject <DefinitionMapData>(documentText); } catch (JsonSerializationException) { } } } return(result); }