Skip to content

Commit

Permalink
tip: Show the .NET version your code is running on
Browse files Browse the repository at this point in the history
  • Loading branch information
deadlydog committed Oct 21, 2023
1 parent fd9213a commit d4facef
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
$tip = [tiPS.PowerShellTip]::new()
$tip.CreatedDate = [DateTime]::Parse('2023-10-21')
$tip.Title = 'Get the .NET version your code is running on'
$tip.TipText = @'
.NET has a FrameworkDescription property that returns the version of .NET your code is running on. This is useful if you want to write code that behaves differently depending on the version of .NET it's running on, or when troubleshooting issues that users may be experiencing.
'@
$tip.Example = @'
# Running the command on PowerShell 7.
> [System.Runtime.InteropServices.RuntimeInformation]::FrameworkDescription
.NET 7.0.11
# Running the command on PowerShell 5.1.
> [System.Runtime.InteropServices.RuntimeInformation]::FrameworkDescription
.NET Framework 4.8.4644.0
'@
$tip.Urls = @(
'https://learn.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.runtimeinformation.frameworkdescription'
'https://twitter.com/JeffHicks/status/1705007619499237525'
)
$tip.Category = [tiPS.TipCategory]::NativeCmdlet # Community, Editor, Module, NativeCmdlet, Performance, Security, Syntax, Terminal, or Other.

# Community: Social events and community resources. e.g. PowerShell Summit, podcasts, etc.
# Editor: Editor tips and extensions. e.g. VSCode, ISE, etc.
# Module: Modules and module tips. e.g. PSScriptAnalyzer, Pester, etc.
# NativeCmdlet: Native cmdlet tips. e.g. Get-Process, Get-ChildItem, Get-Content, etc.
# Performance: Tips to improve runtime performance. e.g. foreach vs ForEach-Object, ForEach-Object -Parallel, etc.
# Security: Security tips. e.g. ExecutionPolicy, Constrained Language Mode, passwords, etc.
# Syntax: Syntax tips. e.g. splatting, pipeline, etc.
# Terminal: Terminal shortcuts and tips. e.g. PSReadLine, Windows Terminal, ConEmu, etc.
# Other: Tips that don't fit into any of the other categories.
11 changes: 11 additions & 0 deletions src/tiPS/PowerShellTips.json
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,17 @@
],
"Category": 2
},
{
"CreatedDate": "2023-10-21T00:00:00",
"Title": "Get the .NET version your code is running on",
"TipText": ".NET has a FrameworkDescription property that returns the version of .NET your code is running on. This is useful if you want to write code that behaves differently depending on the version of .NET it's running on, or when troubleshooting issues that users may be experiencing.",
"Example": "# Running the command on PowerShell 7.\r\n> [System.Runtime.InteropServices.RuntimeInformation]::FrameworkDescription\r\n.NET 7.0.11\r\n\r\n# Running the command on PowerShell 5.1.\r\n> [System.Runtime.InteropServices.RuntimeInformation]::FrameworkDescription\r\n.NET Framework 4.8.4644.0",
"Urls": [
"https://learn.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.runtimeinformation.frameworkdescription",
"https://twitter.com/JeffHicks/status/1705007619499237525"
],
"Category": 3
},
{
"CreatedDate": "2023-10-21T00:00:00",
"Title": "Learn about a random PowerShell cmdlet or topic",
Expand Down

0 comments on commit d4facef

Please sign in to comment.