Sr. Content Developer at Microsoft, working remotely in PA, TechBash conference organizer, former Microsoft MVP, Husband, Dad and Geek.
152623 stories
·
33 followers

Deep C# - The Console

1 Share
Read the whole story
alvinashcraft
21 seconds ago
reply
Pennsylvania, USA
Share this story
Delete

Introducing rnr - A Zero-Dependency Task Runner

1 Share
Meet rnr (pronounced 'runner') - a cross-platform task runner that lives inside your repo. Contributors clone and run, zero friction.
Read the whole story
alvinashcraft
28 seconds ago
reply
Pennsylvania, USA
Share this story
Delete

Announcing DotnetPsCmds - PowerShell CmdLets for .NET

1 Share

DotNet Powershell Commands

Have you ever wondered why there aren't PowerShell Cmdlets similar to dotnet CLI commands?

I've played around with some PowerShell scripts—including some scripts for scaffolding various .NET projects—and some C#-based CmdLets for various things. But I decided to take that experience to the next level by publishing a PowerShell module that provides dotnet CLI functionality while leveraging PowerShell idioms and features.

PowerShell has some interesting features that can make working in the command-line and building scripts a little nicer. One of those features is pipelining. Cmd and Bash have pipes, I know; but PowerShell takes it a step further by supporting object-oriented pipelining. A PowerShell CmdLet can have a .NET object as output (not just text) and can be propagated through the PowerShell command pipeline.

MVP

The initial (pre) release is very much an MVP--it provides what I consider minimal functionality to support scaffolding .NET solutions and projects. It essentially wraps dotnet CLI commands adding some convenience and opinions ("opinionation"?) to defaults and some features.

To get started with the cmdlets, you can import the module from the PowerShell Gallery:

Install-Module -Name Pri.Essentials.DotnetPsCmds

As this release builds on the .NET CLI, the .NET CLI still needs to be installed.

Creating a Solution

To create a solution in the current directory, with a solution name matching the name of the current directory (equivalent of dotnet new sln):

$s = New-DotnetSolution;

The output of this cmdlet is a object-oriented representation of the new solution.

Creating a Project

To create a project (a classlib project) in a new Domain directory with a project name of MyProduct.Domain (equivalent of dotnet new classlib -o Domain -n MyProduct.Domain).

$d = New-DotnetProject 'classlib' Domain MyProduct.Domain;

The output of this cmdlet is a object-oriented representation of the new project.

Adding Package References

With object instances of projects and solutions, we can now re-use those objects for other commands, like adding package references to a project:

$t = New-DotnetProject 'xunit' MyProduct/Tests MyProduct.Tests;
Add-DotnetPackages -PackageIds NSubstitute -Project $t;

Adding Project References

Similar to adding package references, project objects can be re-used when a project needs to reference another project:

$t = New-DotnetProject 'xunit' MyProduct/Tests MyProduct.Tests;
$d = New-DotnetProject 'classlib' Domain MyProduct.Domain;
Add-DotnetProjectReference -Project $d -TargetProject $t;

Leveraging Pipelining

DotNet PowerShell Commands support pipelining. For example, the output of New-DotnetSolution can be piped to New-DotnetProject to add the newly created project to the newly created solution:

New-DotnetSolution | New-DotnetProject 'classlib' Domain MyProduct.Domain;

You can store the solution object in a variable to enable adding multiple new projects to the solution:

$s = New-DotnetSolution;
$s | New-DotnetProject 'classlib' Domain MyProduct.Domain;
$s | New-DotnetProject 'xunit' Test MyProduct.Tests;

And pipelining works with adding package references:

$t = New-DotnetProject 'xunit' MyProduct/Tests MyProduct.Tests;
$t | Add-DotnetPackages -PackageIds NSubstitute;

As well as project references:

$d = New-DotnetProject 'classlib' Domain MyProduct.Domain;
New-DotnetProject 'xunit' Tests MyProduct.Tests `
    | Add-DotnetProjectReference -Project $d;

Or with project references and package references:

$d = New-DotnetProject 'classlib' Domain MyProduct.Domain;
$t = New-DotnetProject 'xunit' Tests MyProduct.Tests `
    | Add-DotnetPackages NSubstitute `
    | Add-DotnetProjectReference -Project $d;

Leveraging Objects

You can leverage properties of objects to avoid repeating yourself when creating solutions and projects with namespaces. For example, rather than having the "MyProduct" portion of the namespace/filename repeated, you can use the solution's Name property (assuming the current directory has the correct name as the "product name"):

$s = New-DotnetSolution;
$d = $s | New-DotnetProject 'classlib' "Domain" "$($s.Name).Domain";
$t = $s | New-DotnetProject 'xunit' "Tests" "$($s.Name).Tests" `
    | Add-DotnetPackages NSubstitute `
    | Add-DotnetProjectReference -Project $d;

Which, with equivalent to the following with dotnet:

dotnet new sln
dotnet new classlib -o Domain -n MyProduct.Domain
del Domain/Class1.cs
dotnet sln add Domain --in-root
dotnet new xunit -o Tests -n MyProduct.Tests
del Tests/UnitTest1.cs
dotnet add Tests package NSubstitute
dotnet add Tests reference Domain
dotnet sln add Tests --in-root

(For details on deleting Class1.cs and UnitTest1.cs, see below.)

Opinionated

I mentioned DotNet PowerShell Commands is opinionated in certain respects, here's where.

Solution Folders For Projects

I noticed recently that adding projects to a solution (dotnet sln add) automatically creates solution folders for projects whose name wasn't identical to the parent folder and doesn't add solution folders when the names are identical. (Using -o and -n with dotnet new <template> creates a project with a different name from the directory name.) Personally, I find it cumbersome to navigate the file system and especially repos like GitHub when I have project folders that match the project file name and fully-qualified project names (for the sake of default namespaces). e.g. repos/Pri.Essentials.DotnetPsCmds/src/Pri.Essentials.DotnetPsCmds/Pri.Essentials.DotnetPsCmds.csproj and tend toward shortened directory names for navigability and readability (repos/DotnetPsCmds/src/DotnetPsCmds/Pri.Essentials.DotnetPsCmds.csproj) because directory listings often just show a less than useful truncated list of folders that appear to have the same name (Maybe this is better solved with support for setting the default namespace when creating a project? But dotnet doesn't support that. 😉)

Unreadable Folder List

The implementation for this currently manifests in DotNet PowerShell Commands by using --in-root with dotnet sln add to avoid the creation of solution folders with new projects.

Class1.cs

Personally, the first thing I do when creating a class library project via dotnet or Visual Studio is to delete the Class1.cs file. DotNet PowerShell Commands automatically deletes this file when it creates a classlib project. I'm assuming users of DotNet PowerShell Commands are intermediate to advanced and feel the same way.

UnitTest1.cs

DotNet PowerShell Commands does the same thing with UnitTest1.cs in xunit/xunit3 projects as it does with Class1.cs in classlib projects.

Extra Features, So Far

Over and above what dotnet provides, DotNet PowerShell Commands also allows creating a custom solution folder when adding a project to a solution via Add-DotnetProject (not to be confused with New-DotnetProject). This is partially to circumvent the opinionated view that hardly anyone would want a solution folder per project by default. But this provides extra value in that if you use the same folder name with the addition multiple projects, all the projects will be grouped in the same solution folder.

$d = New-DotnetProject 'classlib' Domain MyProduct.Domain;
$s = New-DotnetSolution;
$s | Add-DotnetProject -Project $d -SolutionFolder MyFolder;

More details

For more details, please see the open-source project on GitHub. In there you'll find a more thorough README that goes into a bit more detail on CmdLets and examples. You can also create issues or discussions with questions/suggestions in addition to contributing.

I'd like to pull together a simple roadmap for what I'm thinking for this in the near future. Some things I'm thinking so far are:

  • supporting slnx files (by default?)
  • Templated solutions: creating all the parts of common solution templates in a single command.
  • supporting solution-level features like Directory.Build.props, global.json
  • GitHub repo features like workflows, dependabot, etc.
  • Support modifying project-level properties via commands (like GenerateDocumentationFile, PublishRepositoryUrl, etc.)

If you find this useful
I'm a freelance software architect. If you find this post useful and think I can provide value to your team, please reach out to see how I can help. See About for information about the services I provide.

Read the whole story
alvinashcraft
35 seconds ago
reply
Pennsylvania, USA
Share this story
Delete

How to Generate a .NET Banded Report in Your Desktop Application

1 Share
Learn how to generate a .NET banded report in your desktop application. See more from ActiveReports today. Continue reading
Read the whole story
alvinashcraft
45 seconds ago
reply
Pennsylvania, USA
Share this story
Delete

CES 2026: Maker Highlights from the Biggest Tech Show on Earth

1 Share
CES 2026: Maker Highlights from the Biggest Tech Show on Earth

CES has always carried the maker spirit, but this year it felt more baked than ever. We didn’t see rows of 3D printers running as in the recent past. Instead, we saw their output (printed parts, custom enclosures, snapped-together modules) embedded in products. Same with Raspberry Pis and dev boards. They’re not being demoed. They’re […]

The post CES 2026: Maker Highlights from the Biggest Tech Show on Earth appeared first on Make: DIY Projects and Ideas for Makers.

Read the whole story
alvinashcraft
54 seconds ago
reply
Pennsylvania, USA
Share this story
Delete

How Many Suspects Do You Need In A Crime Novel?

1 Share

When we read crime novels, we want to find out who the baddie is. This means that we need a number of suspects from which to choose. But how many suspects do you need in a crime novel?

How Crime Fiction Works

Crime fiction is usually divided into mysteries, thrillers, and horror stories.

  1. Mysteries are stories when the crime has already been committed and a detective-type character (amateur sleuth, private investigator, police detective, etc.) tries to solve it.
  2. Thrillers are stories when a crime is about to be committed and your main character must try to stop it from happening.
  3. Horror stories are when a crime is being committed and the reader is forced to watch the protagonist go through the terror and try to stop the perpetrator.

Whatever type of crime fiction (and their many sub-genres) you choose, you need suspects for the protagonist to interview, chase down, or stop. And you need enough of them to keep the reader interested.

Must-Read: Mystery, Horror, Thriller – What’s The Difference?

How Many Suspects Do You Need In A Crime Novel?

Now that we’ve established there is a crime, we need to include great suspects to keep the story going for 80 000 words.

‘A suspect is a known person accused or suspected of committing a crime. … The term is also related to the terms defendant, the accused, person of interest, and prime suspect.’ (Wikipedia)

Five plausible suspects seem to be the number that most novelists choose.

  1. Cozy mystery author, Elizabeth Spann Craig says: ‘If you have more suspects, you can more easily maintain the element of surprise at the end, but you have to be careful not to confuse the reader. I usually prefer 5 suspects, killing one of them during the course of the book.’
  2. Novelist and Executive Director of Crime Writers of Canada, Melodie Campbell says: ‘Every mystery novel needs at least three good suspects that you can’t dismiss out of hand… Five is even better, particularly for a full length novel.’
  3. Atmosphere Press says: ‘Most successful mysteries feature between four and seven suspects. Too few, and the solution becomes obvious; too many, and readers get lost.’

Fewer than five suspects do not challenge the reader enough. We want them to wonder who committed the crime and to go along with the detective or sleuth for the full length of the novel. More than five can be too many in a book. This can bore your reader and they will lose interest.

People can usually remember four suspects well. So use five, but concentrate more on the four most likely culprits. We are able to easily remember the names, addresses, connections to the victim, and motives of four people.

(In films, it is common to have more suspects, sometimes up to 10. Glass Onion, A Knives Out Mystery has eight suspects.)

9 Common Archetypes For Murder Suspects Include:

  1. The Disgruntled Relative: This person of interest is a classic character trope in crime fiction who has a hidden reason to hate the victim. They may have been cut out of a will or treated badly. They appear to be grieving, but they really have a powerful motive for murder.
  2. The Best Friend: This suspect is rarely thought of as the killer in the beginning, but secrets begin to emerge, revealing them to be a plausible perpetrator of the crime. A betrayal of some sort is usually involved.
  3. The Heir: This character is another common trope motivated by inheritance, power, or covering up financial crimes. The heir to the victim’s money may need it to get out of trouble – or simply because they dislike the power the person holds over them.
  4. The Business Partner/Colleague/Boss: This suspect might have been involved in an illegal deal with the victim. The victim’s death could also stand to benefit them financially. They often provide a strong alibi that the detective struggles to disprove.
  5. The Secret Lover/Rival: The person of interest could have been involved in an affair with the victim, or a rival in a love triangle. Keeping this romantic secret from loved ones is the primary reason they lie to the authorities.
  6. The Authority Figure: This could be the police officer, butler, or doctor who seems above suspicion, but knows damning secrets relating to the victim.
  7. The Disgruntled Employee/Servant: This suspect is often overlooked, but they’re closely acquainted with the victim’s routine and the murder setting. Their motive usually stems from being mistreated or the victim creates a sudden, negative change in their circumstances.
  8. The Outsider With A Past: This character might be new to the victim’s immediate circle, but has a mysterious past connection that provides a motive. They often serve as a red herring, with their suspicious actions designed to distract the reader from the true culprit.
  9. The Serial Killer: This character is the most difficult one to write as the victim seldom knows them.

The General Red Herring Suspect: This person of interest could be any of the above and is designed to look guilty with a strong motive, a lack of alibi, and a compromising situation. This diverts attention from the real killer. They are often mistakenly arrested during the course of the story.

N.B. Each suspect must have:

  1. A motive for committing the crime. Their motives must be believable and have enough weight for them to be considered in the first place. Remember that murder is the usual crime committed in mysteries, thrillers, and horror stories, so the risk is very high for the character. What motivates them to make their choices? To act and to react? Their motivation should matter, be complex, be rational or irrational, but be believable. The usual reasons for murder are love, money, secrets, resentment, and revenge. You can use our post: 7 Deadly Sins To Strengthen Your Antagonist’s Motives if you like.
  2. A link to the victim. Unless you’re writing a random serial killer mystery, the victim and the suspect should know each other. It must be plausible that their paths will cross and that the crime could take place. This usually gives them the opportunity to commit the crime.
  3. Access to the murder weapon. This usually gives them the means to commit the crime.
  4. The ability to commit the crime. This could be as simple as a matter of strength if the murder was committed against someone much stronger than they are.
  5. A reason to be in the book – use sub-plots here. The suspects could be: a love interest; a person who reflects a character’s growth; a person they employ; a person with whom they share a habit or addiction; someone who knows their secret fear; someone who has grown close to them through a shared dream; or someone they have betrayed. The usual suspects include family members, friends, and work colleagues.
  6. A great introduction (by the author). We have to remember them so the author must make them memorable. You could have your detective-type character interact with them before the murder, you could have a non-suspect giving a list of likely perpetrators (and maybe their reasons for committing the crime), or you could have one suspect suggesting more suspects. On meeting the suspects, make sure that their names are distinctly different from each other, mix their sexes, give each one a quirk or a trait that is memorable. They may have a way of dressing or behaving that is difficult to ignore. They may also have a physical feature that is difficult to forget. They may live somewhere that is interesting.
  7. An alibi (or not). Alibis are good ways of ruling out suspects. You can use witnesses, video footage from security cameras, their presence on social media, and physical evidence such as fingerprints or DNA to clear them. Not having an alibi can make them easy targets for red herrings.

Tip: Use red herrings that seem to implicate or clear a suspect. A good red herring could either implicate the wrong person or give a reliable alibi for the real murderer. This makes your protagonist think they’ve caught the killer or discount them as a suspect.

The Last Word

These characters must be interesting. We should remember their interviews, their lies, their truths, and their false leads. At the end of the novel, there will be one suspect left who is guilty. The trip towards this destination should be intriguing.

by Amanda Patterson
© Amanda Patterson

If you liked this blogger’s writing, you may enjoy:

  1. Writing Is An Act Of Courage
  2. A Quick Start Guide To Writing An Inciting Incident
  3. A Quick Start Guide To Foreshadowing
  4. Writing Through The Pain – Tips For Memoirists
  5. Does Your Character Fight, Freeze, Or Flee?
  6. What Is Head-Hopping & Why Should I Avoid It?
  7. 4 Ways To Kickstart A Scene
  8. Help! I Fell In Love With My Antagonist
  9. A Quick Start Guide To Writing Descriptions
  10. A Quick Start Guide To Writing A Memoir

Top Tip: Find out more about our workbooks and online courses in our shop.

The post How Many Suspects Do You Need In A Crime Novel? appeared first on Writers Write.

Read the whole story
alvinashcraft
59 seconds ago
reply
Pennsylvania, USA
Share this story
Delete
Next Page of Stories