Esempio n. 1
0
            private void CreateCandidateObjectCreationProblemForSingleType(StringWriter stringWriter, SequencePoint sp,
                                                                           CodeLocation location, string type,
                                                                           ProblemTrackDatabase database,
                                                                           StringBuilder simpleLog, StringBuilder errorLog)
            {
                try
                {
                    var issue      = new CandidateObjectCreationProblem();
                    var fieldInfos = new HashSet <FieldInfo>();


                    issue.InvolvedFields = fieldInfos;

                    issue.DetailDescription = " add for target object type: " + stringWriter.ToString();
                    issue.BranchLocation    = new BranchInfo(sp.Document, sp.Line, sp.Column, sp.EndColumn,
                                                             location.Method.FullName,
                                                             location.Offset);
                    issue.TargetType       = type;
                    issue.TargetObjectType = type;
                    database.CandidateObjectCreationProblems.Add(issue);
                    simpleLog.AppendLine("add candidate objection issue succeed: " + issue);
                }
                catch (Exception ex)
                {
                    simpleLog.AppendLine("add candidate objection issue faile: ");
                    simpleLog.AppendLine(ex.ToString());
                }
            }
Esempio n. 2
0
            private void CreateCandidateObjectCreationProblem(ProblemTrackDatabase database, CodeLocation location,
                                                              SequencePoint sp, StringWriter stringWriter,
                                                              StringBuilder simpleLog, IEnumerable <Field> fields,
                                                              Field target, StringBuilder errorLog, TypeEx type,
                                                              string targetObjectType)
            {
                TypeEx declaringType;

                try
                {
                    var issue      = new CandidateObjectCreationProblem();
                    var fieldInfos = new HashSet <FieldInfo>();
                    foreach (var field in fields)
                    {
                        if (!field.TryGetDeclaringType(out declaringType))
                        {
                            errorLog.AppendLine("fail to get declaring type of field: " + field.FullName);
                            continue;
                        }
                        fieldInfos.Add(new FieldInfo(field.FullName, field.Type.FullName, declaringType.FullName));
                    }

                    issue.InvolvedFields = fieldInfos;

                    if (target != null)
                    {
                        if (!target.TryGetDeclaringType(out declaringType))
                        {
                            errorLog.AppendLine("fail to get declaring type of field: " + target.FullName);
                        }
                        else
                        {
                            issue.TargetField = new FieldInfo(target.FullName, target.Type.FullName,
                                                              declaringType.FullName);
                        }
                    }

                    issue.DetailDescription = stringWriter.ToString();
                    issue.BranchLocation    = new BranchInfo(sp.Document, sp.Line, sp.Column, sp.EndColumn,
                                                             location.Method.FullName,
                                                             location.Offset);
                    issue.TargetType       = type != null ? type.FullName : "null";
                    issue.TargetObjectType = targetObjectType;
                    database.CandidateObjectCreationProblems.Add(issue);
                    simpleLog.AppendLine("add candidate objection issue succeed: " + issue);
                }
                catch (Exception ex)
                {
                    simpleLog.AppendLine("add candidate objection issue faile: ");
                    simpleLog.AppendLine(ex.ToString());
                }
            }