示例#1
0
        private bool TryFindExistingPluginInSolution(ISolution solution, Version newVersion, out InstallationInfo result)
        {
            var locationDll = solution.GetAllAssemblies()
                              .Select(assembly => assembly.GetLocation())
                              .FirstOrDefault(t => t.Name == PluginPathsProvider.BasicPluginDllFile);

            if (locationDll == null || !locationDll.ExistsFile)
            {
                result = InstallationInfo.DoNotInstall;
                return(false);
            }

            var pluginFiles = solution.GetAllProjects().SelectMany(p => p.
                                                                   GetAllProjectFiles(f =>
            {
                var location = f.Location;
                if (location == null || !location.ExistsFile)
                {
                    return(false);
                }

                return(location.Name == PluginCsFile);
            }))
                              .Select(f => f.Location)
                              .ToList();

            pluginFiles.Add(locationDll);
            result = GetInstallationInfoFromFoundInstallation(pluginFiles, newVersion);
            return(true);
        }
示例#2
0
        private bool TryFindInSolution(ISolution solution, out InstallationInfo result)
        {
            result = ShouldNotInstall;
            var locationDll = solution.GetAllAssemblies()
                              .Select(assembly => assembly.GetLocation())
                              .FirstOrDefault(t => t.Name == PluginPathsProvider.BasicPluginDllFile);

            if (locationDll == null)
            {
                return(false);
            }

            var pluginFiles = solution.GetAllProjects().SelectMany(p => p.
                                                                   GetAllProjectFiles(f =>
            {
                var location = f.Location;
                if (location == null)
                {
                    return(false);
                }

                var fileName = location.Name;
                return(ourPluginCsFile.Contains(fileName));
            }))
                              .Select(f => f.Location)
                              .ToList();

            pluginFiles.Add(locationDll);
            result = ExistingInstallation(pluginFiles);
            return(true);
        }
        public bool SuppressUsageInspectionsOnElement(IDeclaredElement element, out ImplicitUseKindFlags flags)
        {
            ISolution         iSolution     = element.GetSolution();
            IList <IAssembly> allAssemblies = iSolution.GetAllAssemblies();
            bool referencesUnity            =
                allAssemblies.Any(
                    assembly => assembly.Name == "UnityEngine" || assembly.Name == "UnityEditor");

            if (!referencesUnity)
            {
                flags = ImplicitUseKindFlags.Default;
                return(false);
            }
            IClass cls = element as IClass;

            if (cls != null)
            {
                if (m_unitySolutionHelper.IsUnityImplicitType(cls, cls.Module))
                {
                    flags = ImplicitUseKindFlags.InstantiatedNoFixedConstructorSignature;
                    return(true);
                }
            }

            IMethod method = element as IMethod;

            if (method != null && MonoBehaviourUtil.IsEventHandler(method.ShortName))
            {
                ITypeElement containingType = method.GetContainingType();
                if (containingType != null && m_unitySolutionHelper.IsUnityImplicitType(containingType, method.Module))
                {
                    flags = ImplicitUseKindFlags.Access;
                    return(true);
                }
            }

            IField field = element as IField;

            if (field != null)
            {
                if (m_unitySolutionHelper.CheckFieldForUnityImplicits(field, field.Module))
                {
                    // Public fields gets exposed to the Unity Editor and assigned from the UI. But it still should be checked if the field is ever accessed from the code.
                    flags = ImplicitUseKindFlags.Assign;
                    return(true);
                }
            }

            flags = ImplicitUseKindFlags.Default;
            return(false);
        }