Exemplo n.º 1
0
        /// <summary>
        /// Get the text version of all the resolved entities.
        /// </summary>
        /// <param name="cdmCorpus"> The CDM corpus. </param>
        /// <param name="directives"> The directives to use while getting the resolved entities. </param>
        /// <param name="manifest"> The manifest to be resolved. </param>
        /// <param name="spew"> The object used to store the text to be returned. </param>
        /// <returns> The text version of the resolved entities. (it's in a form that facilitates debugging) </returns>
        internal static async Task <string> ListAllResolved(CdmCorpusDefinition cdmCorpus, AttributeResolutionDirectiveSet directives, CdmManifestDefinition manifest, StringSpewCatcher spew = null)
        {
            var seen = new HashSet <string>();
            Func <CdmManifestDefinition, Task> seekEntities = null;

            seekEntities = async(CdmManifestDefinition f) =>
            {
                if (f.Entities != null)
                {
                    if (spew != null)
                    {
                        spew.SpewLine(f.FolderPath);
                    }

                    foreach (CdmEntityDeclarationDefinition entity in f.Entities)
                    {
                        string corpusPath;
                        CdmEntityDeclarationDefinition ent = entity;
                        CdmObject currentFile = f;
                        while (ent is CdmReferencedEntityDeclarationDefinition)
                        {
                            corpusPath = cdmCorpus.Storage.CreateAbsoluteCorpusPath(ent.EntityPath, currentFile);
                            ent        = await cdmCorpus.FetchObjectAsync <CdmReferencedEntityDeclarationDefinition>(corpusPath);

                            currentFile = ent;
                        }
                        corpusPath = cdmCorpus.Storage.CreateAbsoluteCorpusPath(((CdmLocalEntityDeclarationDefinition)ent).EntityPath, currentFile);
                        ResolveOptions resOpt = new ResolveOptions()
                        {
                            StrictValidation = true
                        };
                        CdmEntityDefinition newEnt = await cdmCorpus.FetchObjectAsync <CdmEntityDefinition>(corpusPath, null, resOpt);

                        resOpt.WrtDoc     = newEnt.InDocument;
                        resOpt.Directives = directives;
                        ResolvedEntity resEnt = new ResolvedEntity(resOpt, newEnt);
                        if (spew != null)
                        {
                            resEnt.Spew(resOpt, spew, " ", true);
                        }
                    }
                }
                if (f.SubManifests != null)
                {
                    // folder.SubManifests.ForEach(async f =>
                    foreach (CdmManifestDeclarationDefinition subManifest in f.SubManifests)
                    {
                        string corpusPath = cdmCorpus.Storage.CreateAbsoluteCorpusPath(subManifest.Definition, f);
                        await seekEntities(await cdmCorpus.FetchObjectAsync <CdmManifestDefinition>(corpusPath));
                    }
                }
            };
            await seekEntities(manifest);

            if (spew != null)
            {
                return(spew.GetContent());
            }
            return("");
        }
Exemplo n.º 2
0
        public async static Task ListAllResolved(CdmCorpusDefinition cdmCorpus, AttributeResolutionDirectiveSet directives, CdmManifestDefinition manifest, StringSpewCatcher spew = null)
        {
            ISet <string> seen = new HashSet <string>();
            Func <CdmManifestDefinition, Task> seekEntities = null;

            seekEntities = async(CdmManifestDefinition f) =>
            {
                if (f.Entities != null)
                {
                    if (spew != null)
                    {
                        spew.SpewLine(f.FolderPath);
                    }
                    // manifest.Entities.ForEach(async entity =>
                    foreach (CdmEntityDeclarationDefinition entity in f.Entities)
                    {
                        string corpusPath;
                        CdmEntityDeclarationDefinition ent = entity;
                        CdmObject currentFile = f;
                        while (ent is CdmReferencedEntityDeclarationDefinition)
                        {
                            corpusPath = cdmCorpus.Storage.CreateAbsoluteCorpusPath(ent.EntityPath, currentFile);
                            ent        = await cdmCorpus.FetchObjectAsync <CdmReferencedEntityDeclarationDefinition>(corpusPath);

                            currentFile = (CdmObject)ent;
                        }
                        corpusPath = cdmCorpus.Storage.CreateAbsoluteCorpusPath(((CdmLocalEntityDeclarationDefinition)ent).EntityPath, currentFile);
                        var newEnt = await cdmCorpus.FetchObjectAsync <CdmEntityDefinition>(corpusPath);

                        ResolveOptions resOpt = new ResolveOptions()
                        {
                            WrtDoc = newEnt.InDocument, Directives = directives
                        };
                        ResolvedEntity resEnt = new ResolvedEntity(resOpt, newEnt);
                        if (spew != null)
                        {
                            resEnt.Spew(resOpt, spew, " ", true);
                        }
                    }
                }
                if (f.SubManifests != null)
                {
                    // folder.SubManifests.ForEach(async f =>
                    foreach (CdmManifestDeclarationDefinition subManifest in f.SubManifests)
                    {
                        string corpusPath = cdmCorpus.Storage.CreateAbsoluteCorpusPath(subManifest.Definition, f);
                        await seekEntities(await cdmCorpus.FetchObjectAsync <CdmManifestDefinition>(corpusPath));
                    }
                }
            };
            await seekEntities(manifest);

            if (spew != null)
            {
                File.WriteAllText(@"c:\temp\allResolved.txt", spew.GetContent(), Encoding.UTF8);
            }
        }
Exemplo n.º 3
0
 protected virtual void CheckTypeDependency(ResolveContext rc)
 {
     // verify accessibility
     if (!ResolvedEntity.IsAccessibleAs(ResolvedMemberType))
     {
         if (this is PropertyDeclaration)
         {
             rc.Report.Error(206, Location,
                             "Inconsistent accessibility: property type `" +
                             ResolvedMemberType.ToString() + "' is less " +
                             "accessible than property `" + GetSignatureForError() + "'");
         }
         else if (this is IndexerDeclaration)
         {
             rc.Report.Error(207, Location,
                             "Inconsistent accessibility: indexer return type `" +
                             ResolvedMemberType.ToString() + "' is less " +
                             "accessible than indexer `" + GetSignatureForError() + "'");
         }
         else if (this is MethodCore)
         {
             if (this is OperatorDeclaration)
             {
                 rc.Report.Error(208, Location,
                                 "Inconsistent accessibility: return type `" +
                                 ResolvedMemberType.ToString() + "' is less " +
                                 "accessible than operator `" + GetSignatureForError() + "'");
             }
             else
             {
                 rc.Report.Error(209, Location,
                                 "Inconsistent accessibility: return type `" +
                                 ResolvedMemberType.ToString() + "' is less " +
                                 "accessible than method `" + GetSignatureForError() + "'");
             }
         }
         else if (this is EventDeclaration)
         {
             rc.Report.Error(210, Location,
                             "Inconsistent accessibility: event type `{0}' is less accessible than event `{1}'",
                             ResolvedMemberType.ToString(), GetSignatureForError());
         }
         else
         {
             rc.Report.Error(211, Location,
                             "Inconsistent accessibility: field type `" +
                             ResolvedMemberType.ToString() + "' is less " +
                             "accessible than field `" + GetSignatureForError() + "'");
         }
     }
 }
Exemplo n.º 4
0
        private void AddEntityToDictionary(Dictionary <string, ResolvedEntity[]> keyDictionary, Entity resolvedEntity)
        {
            var existingCheckKey     = BuildExistingCheckKey(resolvedEntity, primaryKeyAttributeMetadataDictionary);
            var resolvedEntityStruct = new ResolvedEntity(resolvedEntity);

            if (!keyDictionary.ContainsKey(existingCheckKey))
            {
                keyDictionary.Add(existingCheckKey, new ResolvedEntity[] { resolvedEntityStruct });
            }
            else
            {
                var resolvedEntitiesOfKey = keyDictionary[existingCheckKey];
                var tempResolvedEntities  = new ResolvedEntity[resolvedEntitiesOfKey.Length + 1];
                resolvedEntitiesOfKey.CopyTo(tempResolvedEntities, 0);
                tempResolvedEntities[tempResolvedEntities.Length - 1] = resolvedEntityStruct;
                keyDictionary[existingCheckKey] = tempResolvedEntities;
            }
        }