Skip to content

Instantly share code, notes, and snippets.

View renatogroffe's full-sized avatar
🎯
Focusing

Renato Groffe renatogroffe

🎯
Focusing
  • Brazil
  • 07:51 (UTC -03:00)
View GitHub Profile
using ConsoleAppPartialProperty.Helpers;
using System.Runtime.InteropServices;
Console.WriteLine("***** Testes com .NET 9 + C# 13 | Partial Property *****");
Console.WriteLine($"Versao do .NET em uso: {RuntimeInformation
.FrameworkDescription} - Ambiente: {Environment.MachineName} - Kernel: {Environment
.OSVersion.VersionString}");
Console.WriteLine();
var selectedDatabases = new string[] { "sqlserver", "mongodb", "postgres", "redis", "mysql" };
using System.Text.RegularExpressions;
namespace ConsoleAppPartialProperty.Helpers;
public static partial class ValidationHelpers
{
[GeneratedRegex("sqlserver|postgres|mysql")]
public static partial Regex IsRelationalDatabase { get; }
}
using ConsoleAppPartialMethod.Helpers;
using System.Runtime.InteropServices;
Console.WriteLine("***** Testes com .NET 8 + GeneratedRegexAttribute + Partial Method *****");
Console.WriteLine($"Versao do .NET em uso: {RuntimeInformation
.FrameworkDescription} - Ambiente: {Environment.MachineName} - Kernel: {Environment
.OSVersion.VersionString}");
Console.WriteLine();
var selectedDatabases = new string[] { "sqlserver", "mongodb", "postgres", "redis", "mysql" };
using System.Text.RegularExpressions;
namespace ConsoleAppPartialMethod.Helpers;
public static partial class ValidationHelpers
{
[GeneratedRegex("sqlserver|postgres|mysql")]
public static partial Regex IsRelationalDatabase();
}
using ConsoleAppIndexEndInitializer.Models;
using System.Runtime.InteropServices;
using System.Text.Json;
Console.WriteLine("***** Testes com .NET 9 + C# 13 | Index from the end em initializer *****");
Console.WriteLine($"Versao do .NET em uso: {RuntimeInformation
.FrameworkDescription} - Ambiente: {Environment.MachineName} - Kernel: {Environment
.OSVersion.VersionString}");
Console.WriteLine();
namespace ConsoleAppIndexEndInitializer.Models;
public class TorneioEsportivo
{
public string? Nome { get; set; }
public Edicao[] UltimasEdicoes { get; set; } = new Edicao[6];
}
public class Edicao
{
"""
This plugin searches for SQL Server, Azure SQL and PostgreSQL connection strings.
"""
import re
from detect_secrets.plugins.base import RegexBasedDetector
class ConnectionStringDetector(RegexBasedDetector):
"""Scans for Connection Strings for SQL Server, Azure SQL and PostgreSQL."""

ASPNETCore8-MinimalAPIs-JWT-Swagger-Extensions-Mermaid-HttpFiles-Mermaid_ContagemAcessos

Exemplo de API REST para contagem de acessos criada com o .NET 8 + ASP.NET Core + Minimal APIs, empregando extensões definidas em uma Class Library para utilização de JWT (JSON Web Tokens) e de configurações para que o Swagger suporte tokens. Inclui arquivos .http para testes a partir do Visual Studio Code.


Fluxo básico

sequenceDiagram
    actor Aplicacao cliente
using System.Runtime.InteropServices;
using System.Text.Json;
Console.WriteLine("***** Testes com .NET 9 | Sobrecarga metodo FromSeconds - TimeSpan *****");
Console.WriteLine($"Versao do .NET em uso: {RuntimeInformation
.FrameworkDescription} - Ambiente: {Environment.MachineName} - Kernel: {Environment
.OSVersion.VersionString}");
string[] amostrasTempo = ["71.715", "71.716", "71.829", "71.830", "71.832"];
foreach (var amostra in amostrasTempo)
string[] amostrasTempo = ["71.715", "71.716", "71.829", "71.830", "71.832"];
foreach (var amostra in amostrasTempo)
{
Console.WriteLine();
var amostraSegundos = JsonSerializer.Deserialize<double>(amostra);
Console.WriteLine($"Tempo em segundos = {amostra}");
Console.WriteLine($"Tempo em segundos (double) = {amostraSegundos}");
var amostraTimeSpan = TimeSpan.FromSeconds(value: amostraSegundos);
Console.WriteLine($"Tempo em segundos (TimeSpan) = {amostraTimeSpan} | TimeSpan.FromSeconds(value)");
}