Exemplo n.º 1
0
		public void Remove (IAssemblyContext ctx)
		{
			if (sources.Remove (ctx)) {
				ctx.Changed -= CtxChanged;
				CtxChanged (null, null);
			}
		}
Exemplo n.º 2
0
        public bool Check(IAssemblyContext assemblyContext, IEnumerable<Dependency> dependencies)
        {
            bool result = true;
            int reorgCount = 0;
            int nextReorg = 200;

            foreach (Dependency d in dependencies) {
                // The group is the globale one (""); or the dependency's left side
                // matches the group's pattern:
                Dependency d1 = d;
                if (_groupRegexes == null || _groupRegexes.Any(r => Regex.IsMatch(d1.UsingItem, r))) {
                    //if (_groupRegexes != null) {
                    //    _groupRegexes.ToString();
                    //}
                    result &= Check(assemblyContext, d);
                    if (++reorgCount > nextReorg) {
                        _forbidden.Sort(_sortOnDescendingHitCount);
                        _allowed.Sort(_sortOnDescendingHitCount);
                        _questionable.Sort(_sortOnDescendingHitCount);
                        nextReorg = 6 * nextReorg / 5 + 200;
                    }
                }
            }

            return result;
        }
Exemplo n.º 3
0
		public void Replace (IAssemblyContext oldCtx, IAssemblyContext newCtx)
		{
			int i = sources.IndexOf (oldCtx);
			if (i != -1) {
				sources [i] = newCtx;
				CtxChanged (null, null);
			}
		}
		public void Remove (IAssemblyContext ctx)
		{
			var prev = sources;
			sources = sources.Remove (ctx);
			if (sources != prev) {
				ctx.Changed -= CtxChanged;
				CtxChanged (null, null);
			}
		}
Exemplo n.º 5
0
 /// <summary>
 /// Adds the given element to the collection
 /// </summary>
 /// <param name="item">The item to add</param>
 public override void Add(IModelElement item)
 {
     if ((this._parent.AssemblyContext_ComponentSpecifiedExecutionTime == null))
     {
         IAssemblyContext assemblyContext_ComponentSpecifiedExecutionTimeCasted = item.As <IAssemblyContext>();
         if ((assemblyContext_ComponentSpecifiedExecutionTimeCasted != null))
         {
             this._parent.AssemblyContext_ComponentSpecifiedExecutionTime = assemblyContext_ComponentSpecifiedExecutionTimeCasted;
             return;
         }
     }
 }
Exemplo n.º 6
0
		public MakefileData ()
		{
			relativeMakefileName = String.Empty;
			buildTargetName = "all";
			cleanTargetName = "clean";
			executeTargetName = String.Empty;
			ParallelProcesses = 1;
			
			assemblyContext = GetMonoRuntimeContext ();
			if (assemblyContext == null)
				integrationEnabled = false;
		}
 /// <summary>
 /// Initializes a new instance of the <see cref="BuildTarget"/> class.
 /// </summary>
 /// <param name="targetAssemblyPath">Path of the target assembly being built.</param>
 /// <param name="outputAssemblyPath">Path for the output assembly.</param>
 /// <param name="assembly"><see cref="Assembly"/> being built.</param>
 /// <param name="assemblyContext"><see cref="AssemblyContext"/> for the <see cref="Assembly"/> being built.</param>
 public BuildTarget(
     string targetAssemblyPath,
     string outputAssemblyPath,
     Assembly assembly,
     IAssemblyContext assemblyContext)
 {
     TargetAssemblyPath = targetAssemblyPath;
     OutputAssemblyPath = outputAssemblyPath;
     Assembly           = assembly;
     AssemblyContext    = assemblyContext;
     AssemblyName       = assembly.GetName();
 }
        /// <summary>
        /// Retrieve the matching type in the Cecil object model
        /// </summary>
        /// <param name="tdec">Reflector type declaration</param>
        /// <returns>Cecil type definition (null if not found)</returns>
        public static TypeDefinition ReflectorTypeToCecilType(ITypeDeclaration tdec)
        {
            IModule moddec = GetModule(tdec);

            IAssemblyContext context = PluginFactory.GetInstance().GetAssemblyContext(moddec.Location);

            if (context != null)
            {
                return(FindMatchingType(context.AssemblyDefinition, tdec));
            }

            return(null);
        }
Exemplo n.º 9
0
 public void SetProject(DotNetProject netProject)
 {
     selection.Clear();
     configureProject = netProject;
     if (netProject != null)
     {
         SetTargetFramework(netProject.AssemblyContext, netProject.TargetFramework);
         Reset();
     }
     else
     {
         targetContext = null;
         targetVersion = null;
         store.Clear();
     }
 }
Exemplo n.º 10
0
        public void HandleItem(object item)
        {
            string           location = PluginFactory.GetInstance().GetModuleLocation(item);
            IAssemblyContext context  = PluginFactory.GetInstance().GetAssemblyContext(location);

            if (context != null)
            {
                m_mdef = context.AssemblyDefinition.MainModule;
            }
            else
            {
                m_mdef = null;
            }
            Definition.Bind(m_mdef);
            CustomAttributes.Bind(m_mdef);
        }
Exemplo n.º 11
0
 /// <summary>
 /// Check all dependencies against dependency rules created
 /// with <c>AddDependencyRules</c>.
 /// </summary>
 /// <returns>true if no dependencies is illegal according to our rules</returns>
 public bool Check(IAssemblyContext assemblyContext, IEnumerable<DependencyRuleGroup> groups, IEnumerable<Dependency> dependencies, bool showUnusedQuestionableRules)
 {
     bool result = true;
     foreach (var g in groups) {
         result &= g.Check(assemblyContext, dependencies);
     }
     foreach (DependencyRuleRepresentation r in _representations) {
         if (showUnusedQuestionableRules && r.IsQuestionableRule && !r.WasHit) {
             Log.WriteInfo("Questionable rule " + r + " was never matched - maybe you can remove it!");
         } else {
             if (Log.IsVerboseEnabled) {
                 Log.WriteInfo("Rule " + r + " was hit " + r.HitCount + " times.");
             }
         }
     }
     return result;
 }
        private void LoadNodeOnDemand(TreeNode node)
        {
            if (node.Nodes.ContainsKey(EXPANDER_NODE_KEY))
            {
                node.Nodes.RemoveAt(node.Nodes.IndexOfKey(EXPANDER_NODE_KEY));
            }
            if ((node.Tag) is IReflectionVisitable)
            {
                IReflectionVisitable visitable = (IReflectionVisitable)node.Tag;
                if (!m_visiteditems.ContainsKey(visitable))
                {
                    visitable.Accept(this);
                    m_visiteditems.Add(visitable, visitable);
                }
            }
            else if ((node.Tag) is IAssemblyWrapper)
            {
                IAssemblyWrapper iasm = (IAssemblyWrapper)node.Tag;

                IAssemblyContext context = PluginFactory.GetInstance().GetAssemblyContext(iasm.Location);
                if (context != null)
                {
                    AssemblyDefinition asmdef = context.AssemblyDefinition;

                    if ((AssemblyRestriction == null) || (asmdef == AssemblyRestriction))
                    {
                        m_nodes.Remove(node.Tag);
                        m_nodes.Add(asmdef, node);
                        node.Tag = asmdef;

                        foreach (ModuleDefinition moddef in asmdef.Modules)
                        {
                            AppendNode(asmdef, moddef, moddef.Types.Count > 0);
                        }
                    }
                    else
                    {
                        node.Tag = "restricted";
                        node.Text += String.Format(" (You can't use this assembly for selection -> restricted to {0})", AssemblyRestriction.Name.Name);
                    }
                }
            }
        }
Exemplo n.º 13
0
        public override void Compile(IAssemblyContext context)
        {
            var cmd = new StringBuilder("gcc -Wall -shared -o ");
            cmd.Append(context.OutputFile);

            foreach (var code in context.Types.SelectMany(t => t.MethodContexts))
                cmd.AppendFormat(" {0}", code.OutputFile);

            string output;
            string error;
            if (Helper.Execute(cmd.ToString(), out error, out output) == 0)
            {
                if (!string.IsNullOrEmpty(error))
                    Helper.Break();

                return;
            }

            Helper.Stop(new ApplicationException(error + output));
        }
Exemplo n.º 14
0
 /// <summary>
 /// Adds the given element to the collection
 /// </summary>
 /// <param name="item">The item to add</param>
 public override void Add(IModelElement item)
 {
     if ((this._parent.Interface == null))
     {
         IInterface interfaceCasted = item.As <IInterface>();
         if ((interfaceCasted != null))
         {
             this._parent.Interface = interfaceCasted;
             return;
         }
     }
     if ((this._parent.ConnectedAssemblyContext == null))
     {
         IAssemblyContext connectedAssemblyContextCasted = item.As <IAssemblyContext>();
         if ((connectedAssemblyContextCasted != null))
         {
             this._parent.ConnectedAssemblyContext = connectedAssemblyContextCasted;
             return;
         }
     }
 }
 /// <summary>
 /// Adds the given element to the collection
 /// </summary>
 /// <param name="item">The item to add</param>
 public override void Add(IModelElement item)
 {
     if ((this._parent.Assembly == null))
     {
         IAssemblyContext assemblyCasted = item.As <IAssemblyContext>();
         if ((assemblyCasted != null))
         {
             this._parent.Assembly = assemblyCasted;
             return;
         }
     }
     if ((this._parent.Container == null))
     {
         FZI.SoftwareEngineering.DeepModeling.TwoLevelADL.Deployment.IContainer containerCasted = item.As <FZI.SoftwareEngineering.DeepModeling.TwoLevelADL.Deployment.IContainer>();
         if ((containerCasted != null))
         {
             this._parent.Container = containerCasted;
             return;
         }
     }
 }
Exemplo n.º 16
0
            /// <summary>
            /// Adds the given element to the collection
            /// </summary>
            /// <param name="item">The item to add</param>
            public override void Add(IModelElement item)
            {
                IAssemblyContext encapsulatedContextsCasted = item.As <IAssemblyContext>();

                if ((encapsulatedContextsCasted != null))
                {
                    this._parent.EncapsulatedContexts.Add(encapsulatedContextsCasted);
                }
                IDelegateConnector delegateConnectorsCasted = item.As <IDelegateConnector>();

                if ((delegateConnectorsCasted != null))
                {
                    this._parent.DelegateConnectors.Add(delegateConnectorsCasted);
                }
                IAssemblyConnector connectorsCasted = item.As <IAssemblyConnector>();

                if ((connectorsCasted != null))
                {
                    this._parent.Connectors.Add(connectorsCasted);
                }
            }
Exemplo n.º 17
0
 /// <summary>
 /// Adds the given element to the collection
 /// </summary>
 /// <param name="item">The item to add</param>
 public override void Add(IModelElement item)
 {
     if ((this._parent.Assembly == null))
     {
         IAssemblyContext assemblyCasted = item.As <IAssemblyContext>();
         if ((assemblyCasted != null))
         {
             this._parent.Assembly = assemblyCasted;
             return;
         }
     }
     if ((this._parent.Container == null))
     {
         IContainer_MM06 containerCasted = item.As <IContainer_MM06>();
         if ((containerCasted != null))
         {
             this._parent.Container = containerCasted;
             return;
         }
     }
 }
Exemplo n.º 18
0
 /// <summary>
 /// Adds the given element to the collection
 /// </summary>
 /// <param name="item">The item to add</param>
 public override void Add(IModelElement item)
 {
     if ((this._parent.SinkRole__EventChannelSinkConnector == null))
     {
         ISinkRole sinkRole__EventChannelSinkConnectorCasted = item.As <ISinkRole>();
         if ((sinkRole__EventChannelSinkConnectorCasted != null))
         {
             this._parent.SinkRole__EventChannelSinkConnector = sinkRole__EventChannelSinkConnectorCasted;
             return;
         }
     }
     if ((this._parent.FilterCondition__EventChannelSinkConnector == null))
     {
         IPCMRandomVariable filterCondition__EventChannelSinkConnectorCasted = item.As <IPCMRandomVariable>();
         if ((filterCondition__EventChannelSinkConnectorCasted != null))
         {
             this._parent.FilterCondition__EventChannelSinkConnector = filterCondition__EventChannelSinkConnectorCasted;
             return;
         }
     }
     if ((this._parent.AssemblyContext__EventChannelSinkConnector == null))
     {
         IAssemblyContext assemblyContext__EventChannelSinkConnectorCasted = item.As <IAssemblyContext>();
         if ((assemblyContext__EventChannelSinkConnectorCasted != null))
         {
             this._parent.AssemblyContext__EventChannelSinkConnector = assemblyContext__EventChannelSinkConnectorCasted;
             return;
         }
     }
     if ((this._parent.EventChannel__EventChannelSinkConnector == null))
     {
         IEventChannel eventChannel__EventChannelSinkConnectorCasted = item.As <IEventChannel>();
         if ((eventChannel__EventChannelSinkConnectorCasted != null))
         {
             this._parent.EventChannel__EventChannelSinkConnector = eventChannel__EventChannelSinkConnectorCasted;
             return;
         }
     }
 }
Exemplo n.º 19
0
        private bool Check(IAssemblyContext assemblyContext, Dependency d)
        {
            bool ok = false;

            if (Log.IsVerboseEnabled)
            {
                Log.WriteInfo("Checking " + d);
            }
            if (_forbidden.Any(r => r.Matches(d)))
            {
                goto DONE;
            }
            if (_allowed.Any(r => r.Matches(d)))
            {
                ok = true;
                goto DONE;
            }
            if (_questionable.Any(r => r.Matches(d)))
            {
                var ruleViolation = new RuleViolation(d, ViolationType.Warning);
                Log.WriteViolation(ruleViolation);
                if (assemblyContext != null)
                {
                    assemblyContext.Add(ruleViolation);
                }
                ok = true;
            }
DONE:
            if (!ok)
            {
                var ruleViolation = new RuleViolation(d, ViolationType.Error);
                Log.WriteViolation(ruleViolation);
                if (assemblyContext != null)
                {
                    assemblyContext.Add(ruleViolation);
                }
            }
            return(ok);
        }
Exemplo n.º 20
0
 /// <summary>
 /// Adds the given element to the collection
 /// </summary>
 /// <param name="item">The item to add</param>
 public override void Add(IModelElement item)
 {
     if ((this._parent.ProvidedRole__AssemblyInfrastructureConnector == null))
     {
         IInfrastructureProvidedRole providedRole__AssemblyInfrastructureConnectorCasted = item.As <IInfrastructureProvidedRole>();
         if ((providedRole__AssemblyInfrastructureConnectorCasted != null))
         {
             this._parent.ProvidedRole__AssemblyInfrastructureConnector = providedRole__AssemblyInfrastructureConnectorCasted;
             return;
         }
     }
     if ((this._parent.RequiredRole__AssemblyInfrastructureConnector == null))
     {
         IInfrastructureRequiredRole requiredRole__AssemblyInfrastructureConnectorCasted = item.As <IInfrastructureRequiredRole>();
         if ((requiredRole__AssemblyInfrastructureConnectorCasted != null))
         {
             this._parent.RequiredRole__AssemblyInfrastructureConnector = requiredRole__AssemblyInfrastructureConnectorCasted;
             return;
         }
     }
     if ((this._parent.ProvidingAssemblyContext__AssemblyInfrastructureConnector == null))
     {
         IAssemblyContext providingAssemblyContext__AssemblyInfrastructureConnectorCasted = item.As <IAssemblyContext>();
         if ((providingAssemblyContext__AssemblyInfrastructureConnectorCasted != null))
         {
             this._parent.ProvidingAssemblyContext__AssemblyInfrastructureConnector = providingAssemblyContext__AssemblyInfrastructureConnectorCasted;
             return;
         }
     }
     if ((this._parent.RequiringAssemblyContext__AssemblyInfrastructureConnector == null))
     {
         IAssemblyContext requiringAssemblyContext__AssemblyInfrastructureConnectorCasted = item.As <IAssemblyContext>();
         if ((requiringAssemblyContext__AssemblyInfrastructureConnectorCasted != null))
         {
             this._parent.RequiringAssemblyContext__AssemblyInfrastructureConnector = requiringAssemblyContext__AssemblyInfrastructureConnectorCasted;
             return;
         }
     }
 }
Exemplo n.º 21
0
 /// <summary>
 /// Adds the given element to the collection
 /// </summary>
 /// <param name="item">The item to add</param>
 public override void Add(IModelElement item)
 {
     if ((this._parent.ResourceContainer_AllocationContext == null))
     {
         IResourceContainer resourceContainer_AllocationContextCasted = item.As <IResourceContainer>();
         if ((resourceContainer_AllocationContextCasted != null))
         {
             this._parent.ResourceContainer_AllocationContext = resourceContainer_AllocationContextCasted;
             return;
         }
     }
     if ((this._parent.AssemblyContext_AllocationContext == null))
     {
         IAssemblyContext assemblyContext_AllocationContextCasted = item.As <IAssemblyContext>();
         if ((assemblyContext_AllocationContextCasted != null))
         {
             this._parent.AssemblyContext_AllocationContext = assemblyContext_AllocationContextCasted;
             return;
         }
     }
     if ((this._parent.Allocation_AllocationContext == null))
     {
         IAllocation allocation_AllocationContextCasted = item.As <IAllocation>();
         if ((allocation_AllocationContextCasted != null))
         {
             this._parent.Allocation_AllocationContext = allocation_AllocationContextCasted;
             return;
         }
     }
     if ((this._parent.EventChannel__AllocationContext == null))
     {
         IEventChannel eventChannel__AllocationContextCasted = item.As <IEventChannel>();
         if ((eventChannel__AllocationContextCasted != null))
         {
             this._parent.EventChannel__AllocationContext = eventChannel__AllocationContextCasted;
             return;
         }
     }
 }
Exemplo n.º 22
0
        /// <summary>
        /// Check all dependencies against dependency rules created
        /// with <c>AddDependencyRules</c>.
        /// </summary>
        /// <returns>true if no dependencies is illegal according to our rules</returns>
        public bool Check(IAssemblyContext assemblyContext, IEnumerable <DependencyRuleGroup> groups, IEnumerable <Dependency> dependencies, bool showUnusedQuestionableRules)
        {
            bool result = true;

            foreach (var g in groups)
            {
                result &= g.Check(assemblyContext, dependencies);
            }
            foreach (DependencyRuleRepresentation r in _representations)
            {
                if (showUnusedQuestionableRules && r.IsQuestionableRule && !r.WasHit)
                {
                    Log.WriteInfo("Questionable rule " + r + " was never matched - maybe you can remove it!");
                }
                else
                {
                    if (Log.IsVerboseEnabled)
                    {
                        Log.WriteInfo("Rule " + r + " was hit " + r.HitCount + " times.");
                    }
                }
            }
            return(result);
        }
Exemplo n.º 23
0
 public void SetTargetFramework(IAssemblyContext targetContext, TargetFramework targetVersion)
 {
     this.targetContext = targetContext;
     this.targetVersion = targetVersion;
 }
Exemplo n.º 24
0
 public ApplicationInstanceFactory(ISystemEnvironment systemEnvironment, IAssemblyContext assemblyContext, IConfigurationReader configurationReader)
 {
     _systemEnvironment   = systemEnvironment;
     _assemblyContext     = assemblyContext;
     _configurationReader = configurationReader;
 }
Exemplo n.º 25
0
		public void Add (IAssemblyContext ctx)
		{
			sources.Add (ctx);
			ctx.Changed += CtxChanged;
			CtxChanged (null, null);
		}
Exemplo n.º 26
0
		void AddRequiredPackages (IAssemblyContext assemblyContext, string variableName, string packageName, PackageContent packageContent)
		{
			SystemPackage package = assemblyContext.GetPackage (packageName);
			if (package != null && !string.IsNullOrEmpty (package.Requires)) {
				foreach (string requiredPackageName in package.Requires.Split (' ')) {
					if (!pkgNameToPkgVarName.ContainsKey (requiredPackageName)) {
						pkgNameToPkgVarName[requiredPackageName] = variableName;
						packageContent.RequiredPackages.Add (requiredPackageName);
					}
					AddRequiredPackages (assemblyContext, variableName, requiredPackageName, packageContent);
				}
			}
		}
 public void Add(IAssemblyContext ctx)
 {
     sources.Add(ctx);
     ctx.Changed += CtxChanged;
     CtxChanged(null, null);
 }
Exemplo n.º 28
0
 public override void Compile(IAssemblyContext context)
 {
     this.Stages.ForEach(stage => stage.Compile(context));
 }
Exemplo n.º 29
0
		public void SetProject (DotNetProject netProject)
		{
			selection.Clear ();
			configureProject = netProject;
			if (netProject != null) {
				SetTargetFramework (netProject.AssemblyContext, netProject.TargetFramework);
				Reset ();
			} else {
				targetContext = null;
				targetVersion = null;
				store.Clear ();
			}
		}
Exemplo n.º 30
0
 /// <summary>
 /// Adds all implementations from the specified assembly context.
 /// </summary>
 /// <param name="context">The context.</param>
 public void Add(IAssemblyContext context)
 {
     this.Context = new MergedAssemblyContext(this.Context, context);
 }
Exemplo n.º 31
0
		void RuntimeSystemAssemblyServiceDefaultRuntimeChanged (object sender, EventArgs e)
		{
			if (composedAssemblyContext != null) {
				composedAssemblyContext.Replace (currentRuntimeContext, TargetRuntime.AssemblyContext);
				currentRuntimeContext = TargetRuntime.AssemblyContext;
			}
			UpdateSystemReferences ();
		}
		public ApplicationInstanceFactory(ISystemEnvironment systemEnvironment, IAssemblyContext assemblyContext, IConfigurationReader configurationReader)
		{
			_systemEnvironment = systemEnvironment;
			_assemblyContext = assemblyContext;
			_configurationReader = configurationReader;
		}
Exemplo n.º 33
0
 private bool Check(IAssemblyContext assemblyContext, Dependency d)
 {
     bool ok = false;
     if (Log.IsVerboseEnabled) {
         Log.WriteInfo("Checking " + d);
     }
     if (_forbidden.Any(r => r.Matches(d))) {
         goto DONE;
     }
     if (_allowed.Any(r => r.Matches(d))) {
         ok = true;
         goto DONE;
     }
     if (_questionable.Any(r => r.Matches(d))) {
         var ruleViolation = new RuleViolation(d, ViolationType.Warning);
         Log.WriteViolation(ruleViolation);
         if (assemblyContext != null) {
             assemblyContext.Add(ruleViolation);
         }
         ok = true;
     }
     DONE:
     if (!ok) {
         var ruleViolation = new RuleViolation(d, ViolationType.Error);
         Log.WriteViolation(ruleViolation);
         if (assemblyContext != null) {
             assemblyContext.Add(ruleViolation);
         }
     }
     return ok;
 }
Exemplo n.º 34
0
 /// <summary>
 /// Instantiates and instance of <see cref="EventProcessorDiscoverer"/>
 /// </summary>
 /// <param name="assemblyContext"></param>
 /// <param name="logger"></param>
 public EventProcessorDiscoverer(IAssemblyContext assemblyContext, IBuildToolLogger logger)
 {
     _assemblyContext = assemblyContext;
     _logger          = logger;
 }
Exemplo n.º 35
0
 /// <summary>
 /// Gets a proxy for the referenced value for a AssemblyContexts of the enclosing SystemArchitecture.
 /// </summary>
 public abstract INotifyValue <IResourceContainer> GetAssemblyContextsProxy(IAssemblyContext reference);
Exemplo n.º 36
0
 public abstract IResourceContainer GetAssemblyContextsValue(IAssemblyContext reference);
Exemplo n.º 37
0
 public void SetTargetFramework (IAssemblyContext targetContext, TargetFramework targetVersion)
 {
     this.targetContext = targetContext;
     this.targetVersion = targetVersion;
 }
Exemplo n.º 38
0
 /// <summary>
 /// Instantiates and instance of <see cref="EventProcessorDiscoverer"/>
 /// </summary>
 /// <param name="assemblyContext"></param>
 /// <param name="buildMessages"></param>
 public EventProcessorDiscoverer(IAssemblyContext assemblyContext, IBuildMessages buildMessages)
 {
     _assemblyContext = assemblyContext;
     _buildMessages   = buildMessages;
 }