Mono.CSharp.Using.VariableDeclaration.CheckIDiposableConversion C# (CSharp) Method

CheckIDiposableConversion() protected method

protected CheckIDiposableConversion ( BlockContext bc, LocalVariable li, Mono.CSharp.Expression initializer ) : void
bc BlockContext
li LocalVariable
initializer Mono.CSharp.Expression
return void
			protected virtual void CheckIDiposableConversion (BlockContext bc, LocalVariable li, Expression initializer)
			{
				var type = li.Type;

				if (type != TypeManager.idisposable_type && !type.ImplementsInterface (TypeManager.idisposable_type, false)) {
					if (TypeManager.IsNullableType (type)) {
						// it's handled in CreateDisposeCall
						return;
					}

					bc.Report.SymbolRelatedToPreviousError (type);
					var loc = type_expr == null ? initializer.Location : type_expr.Location;
					bc.Report.Error (1674, loc, "`{0}': type used in a using statement must be implicitly convertible to `System.IDisposable'",
						type.GetSignatureForError ());

					return;
				}
			}