YES YES YES it is absolutely "illegal" to have the detective as the killer.
the crime fiction genre originates from the intuitionists and their ideas. although disregarding the "golden age" in which they wrote is challenging conventions, this is the first rule for crime fiction. never ever use...