Given the sublime recent reinventions of Henry James and Arthur Conan Doyle, it is not a surprise to find another real-life writer recruited into the fictional ranks.

But adopting Oscar Wilde as a protagonist is a riskier shift, particularly since Gyles Brandreth is inserting his hero into detective fiction.

Since his death in 1900, the great Irish wit has gone from depraved monster to martyr in the public eye, from a man with a wild appetite for rent boys to a victim of late-Victorian hypocrisy.

But whatever improprieties he committed in life, Wilde’s plays are regularly revived and his novel, The Picture of Dorian Gray, is still widely read.

Wilde’s claim that “life imitates art far more than art imitates life” could have haunted Brandreth’s mystery featuring his hero as a Holmesian problem-solver.

But Oscar Wilde and a Death of No Importance is an intriguing tightrope walk, the first in what he hopes will be a nine-book series.

The mystery purports to be an unpublished memoir, circa 1939, by Robert Sherard, who, for 50 years, had kept his promise to Wilde not to reveal one particular tale. But now that his friend has been long dead, Sherard must bear witness.

On August 31, 1889, it transpires, Wilde came upon the dead body of Billy Wood, a 16-year-old boy he had taken under his wing. Even with his throat slit and surrounded by lighted candles, the boy remains exquisite — and Wilde determines to bring his killer to justice.

Despite knowing that he will be undone by any public revelations of this murder, the mercurial Wilde is determined to forge on. Unfortunately, when he and another friend — Arthur Conan Doyle! — return with Sherard to the scene of the crime, the room has been swept of everything: body, incense, blood, furniture.

Bent upon success

This makes Wilde even more determined: “Ennui is the enemy! Adventure is the answer. We shall find the murderer of Billy Wood ... Oscar Wilde masquerading as Sherlock Holmes — why not?”

Much to the reader’s delight, of course, Wilde is easily distracted — rushing off to Oxford or zipping across the channel for several days in Paris. There is also the lurid matter of the mysterious, scarred young woman Sherard keeps spotting Wilde with late at night, when Wilde should be home with his wife and sons.

Over the course of Brandreth’s engaging, often ingenious melodrama — which comes with such Dickensian grotesques as a drunken seaman, a dwarf who seems to have it in for Wilde and a grieving mother who is less forthcoming than she claims — Sherard plays Watson to his friend’s Holmes.

There are also the staples of the early detective novel: dark London nights; a woman wronged, another incapable of escaping her fate; clubs and champagne; devoted wives. And yes, there is more than one delicious scene in which even Conan Doyle is astonished by Wilde’s powers of observation and deduction.

But as the plot thickens and aphorisms and suspects pile up, Brandreth has more in mind than entertainment. Along with the narrator, he seems intent on redeeming Wilde, to the point of whitewashing his hero’s life and predilections.

Had the novel appeared without its extensive armamentarium — including a guide to Brandreth’s works, an interview and reading group tips — you wouldn’t be prompted to look beyond it.

But you may be surprised to learn that Sherard did exist and, though things with Wilde ended badly, published three memoirs of him. It is also odd that Brandreth’s victim shares a surname with Alfred Wood, who colluded in Wilde’s downfall.

Judith Thurman has claimed that “novel-writing seems to be a work of high-minded betrayal and biography a work of dirty-minded fidelity”. There may be such a betrayal in Brandreth’s sanitised adventure, but his portrait of Wilde as “a man of rare heart and rarer genius” is also a pleasure.