Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/324.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# FxCop无法分析程序集_C#_.net_Fxcop - Fatal编程技术网

C# FxCop无法分析程序集

C# FxCop无法分析程序集,c#,.net,fxcop,C#,.net,Fxcop,我的FxCop分析系统中的一些程序集有问题。 除了Api之外,我们项目中的大多数程序集都可以正常工作。FxCop只是在135条消息之后停止分析它们,只有一个例外 这是我得到的异常详细信息 读取模块时遇到以下错误 “TenForce.Execution.Api2.Implementation”:无法解析成员 参考:[TenForce.Execution.Api2.Implementation,版本=1.0.0.0, 文化=中立, PublicKeyToken=null]TenForce.Execu

我的FxCop分析系统中的一些程序集有问题。 除了Api之外,我们项目中的大多数程序集都可以正常工作。FxCop只是在135条消息之后停止分析它们,只有一个例外

这是我得到的异常详细信息

读取模块时遇到以下错误 “TenForce.Execution.Api2.Implementation”:无法解析成员 参考:[TenForce.Execution.Api2.Implementation,版本=1.0.0.0, 文化=中立, PublicKeyToken=null]TenForce.Execution.Api2.Implementation.Helpers.IdGenerator
1+包装器
1::Object

我已经确定所有需要的组件都在一起并且是项目的一部分,但是我不知道如何解决这个问题。 以前有人遇到过这种情况吗

  • FxCop 10.0
  • VisualStudio2010
  • .NET框架4
  • TeamCity测试服务器
编辑 正在为导致问题的类添加源代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Collections.ObjectModel;

namespace TenForce.Execution.Api2.Implementation.Helpers
{
    /// <summary>
    /// <para>This class is responsible for generating the various Ids for the Ts.</para>
    /// </summary>
    public static class IdGenerator<T> where T : class, IEquatable<T>, new()
    {
        /// <summary>
        /// Wraps underlying object. Requires object to have int Id property.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        public class Wrapper<T> : IEquatable<Wrapper<T>>
        {
            private PropertyInfo piId;

            /// <summary>
            /// Wrapper constructor
            /// </summary>
            /// <param name="instance"></param>
            public Wrapper(T instance)
            {
                Object = instance;
                Created = DateTime.Now;
                foreach (var pi in instance.GetType().GetProperties())
                {
                    if (pi.Name.Equals("id", StringComparison.OrdinalIgnoreCase))
                    {
                        piId = pi;
                    }
                }

                if (piId == null)
                {
                    var fullName = instance.GetType().FullName;
                    throw new TypeInitializationException(fullName,
                        new Exception(string.Format("{0} is not compatible with IdGenerator. It requires int Id property to be present", fullName)));
                }
            }

            /// <summary>
            /// Gets or sets wrapped instance Id
            /// </summary>
            public int Id
            {
                get
                {
                    return (int)piId.GetValue(Object, null);
                }
                set
                {
                    piId.SetValue(Object, value, null);
                }
            }

            /// <summary>
            /// Creation date
            /// </summary>
            public DateTime Created;

            /// <summary>
            /// Wrapped instance
            /// </summary>
            public T Object;

            /// <summary>
            /// Implements IEquatable interface
            /// </summary>
            /// <param name="other"></param>
            /// <returns></returns>
            public bool Equals(Wrapper<T> other)
            {
                return Object.Equals(other.Object);
            }
        }

        #region Private Fields

        private static Wrapper<T>[] _mWrappers = new Wrapper<T>[10];
        private static readonly object MPadLock = new object();

        #endregion

        #region Public Members

        /// <summary>
        /// <para>Generates a new Id for the T and assigns it to the T.</para>
        /// </summary>
        /// <param name="obj">The T that needs a new Id generated.</param>
        /// <remarks>The T will be stored inside the generator to keep track of the Id and availability.</remarks>
        public static void GenerateId(T obj)
        {
            lock (MPadLock)
            {
                // Search the array for an empty spot or an expired T.
                int index = Array.FindIndex(_mWrappers, s => s == null || DateTime.Now.Subtract(s.Created).Minutes > 10);

                var wrapper = new Wrapper<T>(obj);

                // If we found such a spot, store the new T in that location,
                // If we did not find such a spot, expand the array and the T at the end.
                if (index > -1) _mWrappers[index] = wrapper;
                else
                {
                    Array.Resize(ref _mWrappers, _mWrappers.Length + 1);
                    _mWrappers[_mWrappers.Length - 1] = wrapper;
                }

                // Always update the Id of the T entity with the negative index of the entity's location.
                wrapper.Id = CalculateId(Array.IndexOf(_mWrappers, wrapper));
            }
        }

        /// <summary>
        /// <para>Releases the Id generated for the T and releases the location that was held by the T.</para>
        /// </summary>
        /// <param name="obj">The T that needs to be released.</param>
        /// <remarks>The T will be removed from the generator and it's Id will be reset to zero !!!</remarks>
        public static void ReleaseId(T obj)
        {
            lock (MPadLock)
            {
                var wrapper = new Wrapper<T>(obj);
                if (wrapper.Id >= 0) return;
                int index = Array.IndexOf(_mWrappers, wrapper);
                Array.Clear(_mWrappers, index, 1);
                wrapper.Id = 0;
            }
        }

        /// <summary>
        /// <para>Fetches the specified T from the IdGenerator.</para>
        /// </summary>
        /// <param name="id">The unique identifier of the T.</param>
        /// <returns>The T with the matching Id or the default instance if not found.</returns>
        public static T Fetch(int id)
        {
            lock (MPadLock)
            {
                var found = Array.Find(_mWrappers, s => s != null && s.Id == id);
                return found == null ? new T() : found.Object;
            }
        }

        /// <summary>
        /// <para>Updates the matching T entity inside the Generator with the new one.</para>
        /// </summary>
        /// <param name="obj">The T that needs to be updated.</param>
        public static void Update(T obj)
        {
            lock (MPadLock)
            {
                int index = Array.IndexOf(_mWrappers, obj);
                if (index == -1) return;
                var wrapped = new Wrapper<T>(obj);
                _mWrappers[index] = wrapped;
                wrapped.Id = CalculateId(index);
                wrapped.Created = DateTime.Now;
            }
        }

        /// <summary>
        /// <para>Retrieves all the Ts currently available in the application.</para>
        /// </summary>
        /// <returns>An enumerable collection containing all the T entities.</returns>
        public static IEnumerable<T> ListAll()
        {
            lock (MPadLock)
            {
                return new ReadOnlyCollection<T>(_mWrappers.Select(s => s == null ? null : s.Object).Where(o => o != null).ToList());
            }
        }

        #endregion

        #region Private Members

        /// <summary>
        /// <para>Calculates the negative id for an entity based upon the zero-based index.</para>
        /// </summary>
        /// <param name="index">The zero-based index of the entity who's Id needs to be calculated.</param>
        /// <returns>The new Id for the entity.</returns>
        private static int CalculateId(int index)
        {
            return (index * -1) - 1;
        }
        #endregion
    }
}
使用系统;
使用System.Collections.Generic;
使用System.Linq;
运用系统反思;
使用System.Collections.ObjectModel;
命名空间TenForce.Execution.Api2.Implementation.Helpers
{
/// 
///此类负责为Ts生成各种ID。
/// 
公共静态类IdGenerator,其中T:class,IEquatable,new()
{
/// 
///包装基础对象。要求对象具有int Id属性。
/// 
/// 
公共类包装器:IEquatable
{
私人财产信息piId;
/// 
///包装构造函数
/// 
/// 
公共包装器(T实例)
{
对象=实例;
Created=DateTime.Now;
foreach(实例.GetType().GetProperties()中的var pi)
{
if(pi.Name.Equals(“id”,StringComparison.OrdinalIgnoreCase))
{
piId=pi;
}
}
如果(piId==null)
{
var fullName=instance.GetType().fullName;
抛出新的TypeInitializationException(全名,
新异常(string.Format(“{0}与IdGenerator不兼容。它要求存在int Id属性”,fullName));
}
}
/// 
///获取或设置包装实例Id
/// 
公共整数Id
{
得到
{
返回(int)piId.GetValue(Object,null);
}
设置
{
设置值(对象,值,空);
}
}
/// 
///创建日期
/// 
创建公共日期时间;
/// 
///包装实例
/// 
公众反对;
/// 
///实现IEquatable接口
/// 
/// 
/// 
公共布尔等于(其他)
{
返回Object.Equals(其他.Object);
}
}
#区域专用字段
私有静态包装器[]_mWrappers=新包装器[10];
私有静态只读对象MPadLock=新对象();
#端区
#地区公众成员
/// 
///为T生成新Id并将其分配给T。
/// 
///需要生成新Id的T。
///T将存储在发电机内,以跟踪Id和可用性。
公共静态无效生成ID(T obj)
{
锁(MPadLock)
{
//在数组中搜索空点或过期的T。
int index=Array.FindIndex(_mwrapers,s=>s==null | | | DateTime.Now.Subtract(s.Created.Minutes>10);
var wrapper=新包装(obj);
//如果我们找到这样一个地方,把新的T储存在那个地方,
//如果我们没有找到这样一个点,则展开数组和末尾的T。
如果(索引>-1)\u mWrappers[index]=包装器;
其他的
{
Array.Resize(ref _mWrappers,_mWrappers.Length+1);
_mWrappers[_mWrappers.Length-1]=包装器;
}
//始终使用实体位置的负索引更新T实体的Id。
wrapper.Id=CalculateId(Array.IndexOf(_mWrappers,wrapper));
}
}
/// 
///释放为T生成的Id并释放T持有的位置。
/// 
///需要释放的T。
///T将从发电机上移除,其Id将重置为零!!!
公共静态无效释放ID(T obj)
{
锁(MPadLock)
{
var wrapper=新包装(obj);
如果(wrapper.Id>=0)返回;
int index=Array.IndexOf(_mWrappers,wrapper);
数组。清除(_mWrappers,索引,1);
包装器Id=0;
}
}
/// 
///从IdGenerator获取指定的T。
/// 
///T的唯一标识符。
///具有匹配Id或默认实例(如果未找到)的T。
公共静态T获取(int-id)
{
锁(MPadLock)
{
var found=Array.Find(_mwrapers,s=>s!=null&&s.Id==Id);
return found==null?new T():found.Object;
}
}
/// 
///使用新实体更新生成器中匹配的T实体。
/// 
///需要更新的T。
公共静态无效更新(T obj)
{
锁(MPadLock)
{