Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NullableContext"/> class. This constructor should only be used for root contexts with no parent
        /// contexts.
        /// </summary>
        internal NullableContext(ICustomAttributeProvider attributeProvider, WeavingContext weavingContext)
        {
            WeavingContext = weavingContext;

            _isNullable        = false;
            _nullChecksEnabled = true;

            ProcessAttributes(attributeProvider, ref _isNullable, ref _nullChecksEnabled);
        }
Esempio n. 2
0
        /// <summary>
        /// Walks the parent hierarchy of contexts to find the cached generic parameter nullability.
        /// </summary>
        public bool GetGenericParameterIsNullable(GenericParameter parameter)
        {
            if (parameter.Owner != Method)
            {
                return(TypeContext.GetGenericParameterIsNullable(parameter));
            }

            var paramInfo = GenericParameters.FirstOrDefault(p => p.Parameter == parameter);

            if (paramInfo.Parameter == null)
            {
                WeavingContext.WriteError($"Could not resolve generic parameter '{parameter}': parameter not found.");
                return(true);
            }

            return(paramInfo.Nullable);
        }
 public ModuleContext(ModuleDefinition module, WeavingContext weavingContext) : base(module, new AssemblyContext(module.Assembly, weavingContext))
 {
     Module = module;
 }
 public AssemblyContext(AssemblyDefinition assembly, WeavingContext weavingContext) : base(assembly, weavingContext)
 {
 }