コード例 #1
0
ファイル: RecursiveLock2Rule.cs プロジェクト: dbremner/smokey
        public void VisitBegins(BeginMethods begin)
        {
            Log.DebugLine(this, "-----------------------------------");
            Log.DebugLine(this, "{0}", begin.Type);

            m_current = new Entry();
        }
コード例 #2
0
ファイル: NoStaticRemoveRule.cs プロジェクト: dbremner/smokey
        public void VisitBegin(BeginMethods begin)
        {
            m_fields.Clear();
            m_table.Clear();

            foreach (FieldDefinition field in begin.Type.Fields)
            {
                if (field.IsPrivate && field.IsStatic)
                {
                    string key = DoIsCollection(field.FieldType);
                    if (key != null)
                    {
                        Log.DebugLine(this, "-----------------------------------");
                        Log.DebugLine(this, "{0:F} has a private static collection named {1}", begin.Type, field.Name);

                        if (DoHasReferenceElements(field.FieldType))
                        {
                            Log.DebugLine(this, "and the element types are reference types");
                            m_fields.Add(field);
                            m_table.Add(field, new Entry(key));
                        }
                    }
                }
            }
        }
コード例 #3
0
        public void VisitBegin(BeginMethods begin)
        {
            Log.DebugLine(this, "-----------------------------------");
            Log.DebugLine(this, "{0}", begin.Type);

            m_foundEquals = false;
        }
コード例 #4
0
        public void VisitBegin(BeginMethods begin)
        {
            m_disposable = false;

            TypeDefinition baseType = Cache.FindType(begin.Type.BaseType);

            if (!begin.Type.IsSealed && !begin.Type.IsNestedPrivate && !begin.Type.IsCompilerGenerated())
            {
                if (begin.Type.TypeImplements("System.IDisposable"))
                {
                    if (baseType == null || !baseType.TypeOrBaseImplements("System.IDisposable", Cache))                        // don't check types with redundent IDisposable declarations
                    {
                        if (!begin.Type.IsInterface)
                        {
                            m_disposable = true;
                        }
                    }
                }
            }
            m_hasUnaryDispose = false;

            if (m_disposable)
            {
                Log.DebugLine(this, "-----------------------------------");
                Log.DebugLine(this, "{0}", begin.Type);
            }
        }
コード例 #5
0
        public void VisitBegin(BeginMethods begin)
        {
            Log.DebugLine(this, "-----------------------------------");
            Log.DebugLine(this, "{0}", begin.Type);

            m_equalities.Clear();
            m_properties.Clear();
        }
コード例 #6
0
        public void VisitBegin(BeginMethods begin)
        {
            Log.DebugLine(this, "-----------------------------------");
            Log.DebugLine(this, "{0}", begin.Type.FullName);

            m_type = begin.Type;
            m_types.Clear();
        }
コード例 #7
0
ファイル: SchizoidTypeRule.cs プロジェクト: dbremner/smokey
        public void VisitBegin(BeginMethods begin)
        {
            Log.DebugLine(this, "-----------------------------------");
            Log.DebugLine(this, "{0}", begin.Type);

            m_needsCheck = begin.Type.Methods.Count >= 6 && begin.Type.Fields.Count >= 6;
            m_type       = begin.Type;
            m_method     = null;
            m_partitions.Clear();
        }
コード例 #8
0
        public void VisitBegin(BeginMethods begin)
        {
            m_notSerializable = !begin.Type.TypeOrBaseImplements("System.Runtime.Serialization.ISerializable", Cache);
            m_hasMethod       = false;

            if (m_notSerializable)
            {
                Log.DebugLine(this, "-----------------------------------");
                Log.DebugLine(this, "{0}", begin.Type);
            }
        }
コード例 #9
0
ファイル: HungarianRule.cs プロジェクト: dbremner/smokey
        public void VisitBegin(BeginMethods begin)
        {
            Log.DebugLine(this, "-----------------------------------");
            Log.DebugLine(this, "checking {0}", begin.Type);

            m_names.Clear();

            foreach (FieldDefinition f in begin.Type.Fields)
            {
                DoAdd(f.Name);
            }
        }
コード例 #10
0
        public void VisitBegin(BeginMethods begin)
        {
            m_type       = begin.Type;
            m_disposable = m_type.BaseImplements("System.IDisposable", Cache) && !m_type.IsCompilerGenerated();

            m_hasFinalizer = false;
            m_hasDispose   = false;

            m_disposeMethod = null;
            m_hasBaseCall   = false;

            if (m_disposable)
            {
                Log.DebugLine(this, "-----------------------------------");
                Log.DebugLine(this, "{0}", m_type);
            }
        }
コード例 #11
0
        public void VisitBegin(BeginMethods begin)
        {
            Log.DebugLine(this, "-----------------------------------");
            Log.DebugLine(this, "{0:F}", begin.Type);

            m_fields.Clear();

            if (begin.Type.Constructors.Count > 0)              // some of the types in the 1.9 system dll's have no ctors...
            {
                foreach (FieldDefinition field in begin.Type.Fields)
                {
                    if (field.IsPrivate && !field.IsLiteral)
                    {
                        if (!field.FieldType.IsValueType && !field.IsCompilerControlled)
                        {
                            m_fields.Add(field.Name);
                        }
                    }
                }
            }
        }
コード例 #12
0
ファイル: DisposableRule.cs プロジェクト: dbremner/smokey
        public void VisitBegin(BeginMethods begin)
        {
            m_type       = begin.Type;
            m_disposable = begin.Type.TypeOrBaseImplements("System.IDisposable", Cache) && !m_type.IsCompilerGenerated();

            m_hasFinalizer           = false;
            m_supressWasCalled       = false;
            m_hasVirtualDispose      = false;
            m_hasPublicDispose       = false;
            m_hasNonProtectedDispose = false;
            m_hasNonVirtualDispose   = false;
            m_disposeThrows          = false;
            m_hasNativeFields        = false;

            m_badDisposeNames.Clear();
            m_illegalDisposeNames.Clear();

            m_disposableFields.Clear();

            m_noThrowMethods = string.Empty;

            m_hasNullCall = false;
            m_ownedFields.Clear();

            if (m_disposable)
            {
                Log.DebugLine(this, "-----------------------------------");
                Log.DebugLine(this, "{0}", m_type);
            }

            // We can't visit fields using the dispatcher because we're kicking
            // the visit off with BeginMethods instead of BeginType so we have
            // to manually visit them.
            foreach (FieldDefinition field in m_type.Fields)
            {
                VisitField(field);
            }
        }
コード例 #13
0
ファイル: AnalyzeAssembly.cs プロジェクト: dbremner/smokey
        private void DoCheckMethods(AssemblyCache cache, string[] onlyType)
        {
            Profile.Start("CheckMethods");

            foreach (KeyValuePair <TypeDefinition, List <MethodInfo> > entry in cache.TypeMethods)
            {
                if (DoNameNeedsCheck(entry.Key.FullName, onlyType))
                {
                    BeginMethods begin = new BeginMethods(entry.Key);
                    m_checker.Dispatcher.Dispatch(begin);

                    foreach (MethodInfo method in entry.Value)
                    {
                        m_checker.Check(method);
                    }

                    EndMethods end = new EndMethods(entry.Key);
                    m_checker.Dispatcher.Dispatch(end);
                }
            }

            Profile.Stop("CheckMethods");
        }
コード例 #14
0
        // One possible improvement is to use a real hash of the block instead of simply
        // the block length. This would significantly cut down on false matches, but it
        // also require us to revisit instructions which tends to blow. From examination
        // it appears that we compare very few blocks so a hash doesn't seem terribly
        // useful.
        public void VisitBegin(BeginMethods begin)
        {
            Unused.Value = begin;

            m_table.Clear();
        }
コード例 #15
0
 public void VisitBegin(BeginMethods begin)
 {
     Log.DebugLine(this, "-----------------------------------");
     Log.DebugLine(this, "{0}", begin.Type);
 }