Пример #1
0
        public static FindTargetStatus FindExistingTargetItem(ProjectItemModel source, IGenerationOptions options, out ProjectItem targetItem)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

#pragma warning disable VSTHRD010
            var nameParts = VsProjectHelper.GetNameParts(source.Item);
            targetItem = null;

            var targetProject = source.TargetProject;
            if (targetProject == null)
            {
                return(FindTargetStatus.ProjectNotFound);
            }

            var targetProjectItems = FindTargetFolder(targetProject, nameParts, false, out _);
            if (targetProjectItems == null)
            {
                return(FindTargetStatus.FolderNotFound);
            }

            var extension = Path.GetExtension(source.FilePath);
            var baseName  = Path.GetFileNameWithoutExtension(source.FilePath);

            var testFileName = options.GetTargetFileName(baseName);
            targetItem = targetProjectItems.OfType <ProjectItem>().FirstOrDefault(x => string.Equals(x.Name, testFileName + extension, StringComparison.OrdinalIgnoreCase));
            return(targetItem == null ? FindTargetStatus.FileNotFound : FindTargetStatus.Found);

#pragma warning restore VSTHRD010
        }
 public static bool IsSupported(ProjectItemModel item)
 {
     return(item?.FilePath != null && item.FilePath.EndsWith(".cs", StringComparison.OrdinalIgnoreCase));
 }