Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,38 @@
# generated by dependadotnet
# https://github.com/dotnet/core/tree/master/samples/dependadotnet
version: 2
updates:
updates:
# GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
groups:
github-actions:
patterns: ["*"]
schedule:
interval: "weekly"
cooldown:
default-days: 7
- package-ecosystem: "nuget"
directory: "/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.class/fs" #fontlink1.fsproj
schedule:
interval: "weekly"
day: "wednesday"
open-pull-requests-limit: 5
open-pull-requests-limit: 5
- package-ecosystem: "nuget"
directory: "/samples/snippets/csharp/api/system.reflection.metadata/metadatareader" #MetadataReaderSnippets.csproj
schedule:
interval: "weekly"
day: "wednesday"
open-pull-requests-limit: 5
open-pull-requests-limit: 5
- package-ecosystem: "nuget"
directory: "/samples/snippets/csharp/VS_Snippets_CLR_System/system.collections.generic.equalitycomparer.default/cs" #cs.csproj
schedule:
interval: "weekly"
day: "wednesday"
open-pull-requests-limit: 5
open-pull-requests-limit: 5
- package-ecosystem: "nuget"
directory: "/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.collections.generic.equalitycomparer.default/vb" #vb.vbproj
schedule:
interval: "weekly"
day: "wednesday"
open-pull-requests-limit: 5
open-pull-requests-limit: 5
4 changes: 2 additions & 2 deletions .github/workflows/check-for-build-warnings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
pull-requests: write
steps:
- name: Harden Runner
uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
uses: step-security/harden-runner@e14015d583714f6e62063499dc959a02595150a1 # v2.21.1
with:
egress-policy: audit

- uses: dotnet/docs-tools/actions/status-checker@main
- uses: dotnet/docs-tools/actions/status-checker@78c0756b60e5046dd55295c4a9369b20ffad6b34 # main
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions .github/workflows/live-protection.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ jobs:

steps:
- name: Harden Runner
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4
uses: step-security/harden-runner@e14015d583714f6e62063499dc959a02595150a1 # v2.21.1
with:
egress-policy: audit

- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea
- uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3
env:
LIVE_BASE: ${{ github.base_ref == 'live' && github.head_ref != 'main' }}
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ops-build-reporter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ jobs:
pull-requests: write
steps:
- name: Harden Runner
uses: step-security/harden-runner@05e31511f85b41b11d1cf0ef85d0992719546e2c # v2.21.0
uses: step-security/harden-runner@e14015d583714f6e62063499dc959a02595150a1 # v2.21.1
with:
egress-policy: audit

- uses: dotnet/docs-tools/actions/ops-build-reporter@main
- uses: dotnet/docs-tools/actions/ops-build-reporter@78c0756b60e5046dd55295c4a9369b20ffad6b34 # main
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
max_wait_time_minutes: 40
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/quest-bulk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,23 @@ jobs:

- name: Azure OpenID Connect
id: azure-oidc-auth
uses: dotnet/docs-tools/.github/actions/oidc-auth-flow@main
uses: dotnet/docs-tools/.github/actions/oidc-auth-flow@78c0756b60e5046dd55295c4a9369b20ffad6b34 # main
with:
client-id: ${{ secrets.CLIENT_ID }}
tenant-id: ${{ secrets.TENANT_ID }}
audience: ${{ secrets.OSMP_API_AUDIENCE }}

- name: Azure DevOps OpenID Connect
id: azure-devops-oidc-auth
uses: dotnet/docs-tools/.github/actions/oidc-auth-flow@main
uses: dotnet/docs-tools/.github/actions/oidc-auth-flow@78c0756b60e5046dd55295c4a9369b20ffad6b34 # main
with:
client-id: ${{ secrets.CLIENT_ID }}
tenant-id: ${{ secrets.TENANT_ID }}
audience: ${{ secrets.QUEST_AUDIENCE }}

- name: bulk-sequester
id: bulk-sequester
uses: dotnet/docs-tools/actions/sequester@main
uses: dotnet/docs-tools/actions/sequester@78c0756b60e5046dd55295c4a9369b20ffad6b34 # main
env:
ImportOptions__ApiKeys__GitHubToken: ${{ secrets.GITHUB_TOKEN }}
ImportOptions__ApiKeys__QuestAccessToken: ${{ steps.azure-devops-oidc-auth.outputs.access-token }}
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/quest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ jobs:

- name: Azure OpenID Connect
id: azure-oidc-auth
uses: dotnet/docs-tools/.github/actions/oidc-auth-flow@main
uses: dotnet/docs-tools/.github/actions/oidc-auth-flow@78c0756b60e5046dd55295c4a9369b20ffad6b34 # main
with:
client-id: ${{ secrets.CLIENT_ID }}
tenant-id: ${{ secrets.TENANT_ID }}
audience: ${{ secrets.OSMP_API_AUDIENCE }}

- name: Azure DevOps OpenID Connect for manual test runs
id: azure-devops-oidc-auth
uses: dotnet/docs-tools/.github/actions/oidc-auth-flow@main
uses: dotnet/docs-tools/.github/actions/oidc-auth-flow@78c0756b60e5046dd55295c4a9369b20ffad6b34 # main
with:
client-id: ${{ secrets.CLIENT_ID }}
tenant-id: ${{ secrets.TENANT_ID }}
Expand All @@ -54,7 +54,7 @@ jobs:
- name: manual-sequester
if: ${{ github.event_name == 'workflow_dispatch' }}
id: manual-sequester
uses: dotnet/docs-tools/actions/sequester@main
uses: dotnet/docs-tools/actions/sequester@78c0756b60e5046dd55295c4a9369b20ffad6b34 # main
env:
ImportOptions__ApiKeys__GitHubToken: ${{ secrets.GITHUB_TOKEN }}
ImportOptions__ApiKeys__AzureAccessToken: ${{ steps.azure-oidc-auth.outputs.access-token }}
Expand All @@ -70,7 +70,7 @@ jobs:
- name: auto-sequester
if: ${{ github.event_name != 'workflow_dispatch' }}
id: auto-sequester
uses: dotnet/docs-tools/actions/sequester@main
uses: dotnet/docs-tools/actions/sequester@78c0756b60e5046dd55295c4a9369b20ffad6b34 # main
env:
ImportOptions__ApiKeys__GitHubToken: ${{ secrets.GITHUB_TOKEN }}
ImportOptions__ApiKeys__AzureAccessToken: ${{ steps.azure-oidc-auth.outputs.access-token }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/snippets5000.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@ jobs:
steps:
# Checkout the repository for the PR
- name: Harden Runner
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
uses: step-security/harden-runner@e14015d583714f6e62063499dc959a02595150a1 # v2.21.1
with:
egress-policy: audit

- name: Checkout repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 #@v7.0.0
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 #@v7.0.1

# Get the latest preview SDK (or sdk not installed by the runner)
- name: Set up .NET
if: ${{ env.DOTNET_DO_INSTALL == 'true' }}
uses: actions/setup-dotnet@9a946fdbd5fb07b82b2f5a4466058b876ab72bb2 #@5.3.0
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 #@6.0.0
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
dotnet-quality: ${{ env.DOTNET_QUALITY }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/version-sweep.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

name: 'target supported version'

# Controls when the action will run.
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
schedule:
Expand All @@ -27,7 +27,7 @@ jobs:
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

# Runs a single command using the runners shell
- name: 'Print manual run reason'
Expand All @@ -39,7 +39,7 @@ jobs:
# Start the .NET version sweeper, scan projects/slns for non-LTS (or currrent) versions
- name: .NET version sweeper
id: dotnet-version-sweeper
uses: dotnet/versionsweeper@main
uses: dotnet/versionsweeper@4db106fb89f4c6191a1e3901f953b1aae05331b5 # main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,56 +1,18 @@
// System.Reflection.Emit.ModuleBuilder.DefineDocument

/*
The following example demonstrates the 'DefineDocument' method
of 'ModuleBuilder' class.
A dynamic assembly with a module in it is created in 'CodeGenerator' class.
It gets the object representing the defined document using the method
'DefineDocument'.
*/
// <Snippet1>
using System;
using System;
using System.Diagnostics.SymbolStore;
using System.Reflection;
using System.Reflection.Emit;
using System.Resources;
using System.Diagnostics.SymbolStore;

namespace ILGenServer
{
public class CodeGenerator
{
ModuleBuilder myModuleBuilder ;
AssemblyBuilder myAssemblyBuilder ;

public CodeGenerator()
{

// Get the current application domain for the current thread.
AppDomain currentDomain = AppDomain.CurrentDomain;
AssemblyName myAssemblyName = new AssemblyName();
myAssemblyName.Name = "TempAssembly";

// Define a dynamic assembly in the current domain.
myAssemblyBuilder =
currentDomain.DefineDynamicAssembly
(myAssemblyName, AssemblyBuilderAccess.RunAndSave);
// Define a dynamic module in "TempAssembly" assembly.
myModuleBuilder =
myAssemblyBuilder.DefineDynamicModule("TempModule","Resource.mod",true);
// <Snippet1>
AssemblyName assemblyName = new("TempAssembly");
PersistedAssemblyBuilder assemblyBuilder = new(assemblyName, typeof(object).Assembly);
ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule("TempModule");

// Define a document for source.on 'TempModule' module.
ISymbolDocumentWriter myDocument =
myModuleBuilder.DefineDocument("RTAsm.il", SymDocumentType.Text,
SymLanguageType.ILAssembly,SymLanguageVendor.Microsoft);
ISymbolDocumentWriter document = moduleBuilder.DefineDocument(
"RTAsm.il",
SymLanguageType.ILAssembly,
SymLanguageVendor.Microsoft,
SymDocumentType.Text);

Console.WriteLine("The object representing the defined document is:"+myDocument);
}
}
public class CallerClass
{
public static void Main()
{
CodeGenerator myGenerator = new CodeGenerator();
}
}
}
// </Snippet1>
Console.WriteLine($"The object representing the defined document is:{document}");
// </Snippet1>
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0-windows</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<TargetFramework>net10.0</TargetFramework>
</PropertyGroup>

</Project>
27 changes: 12 additions & 15 deletions snippets/csharp/System.Diagnostics/BooleanSwitch/Enabled/source.cs
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
using System;
using System.Diagnostics;
using System.Windows.Forms;

public class Form1 : Form
public class Form1
{
protected TextBox textBox1;
// <Snippet1>
//Class level declaration.
/* Create a BooleanSwitch for data.*/
static BooleanSwitch dataSwitch = new BooleanSwitch("Data", "DataAccess module");
// Class-level declaration.
// Create a BooleanSwitch for data.
private static readonly BooleanSwitch s_dataSwitch = new("Data", "DataAccess module");

static public void MyMethod(string location)
public static void MyMethod(string location)
{
//Insert code here to handle processing.
if (dataSwitch.Enabled)
Console.WriteLine("Error happened at " + location);
// Insert code here to handle processing.
if (s_dataSwitch.Enabled)
{
Console.WriteLine($"Error happened at {location}");
}
}

public static void Main(string[] args)
{
//Run the method that writes an error message specifying the location of the error.
MyMethod("in Main");
}
// Run the method that writes an error message specifying the location of the error.
public static void Main() => MyMethod("in Main");

// </Snippet1>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SomeClass.Run();
Form1.Run(args);
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0-windows</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<StartupObject>SomeClass</StartupObject>
<TargetFramework>net10.0</TargetFramework>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
public class SomeClass
{
// <Snippet2>
private static BooleanSwitch boolSwitch = new BooleanSwitch("mySwitch",
private static readonly BooleanSwitch s_boolSwitch = new("mySwitch",
"Switch in config file");

public static void Main()
public static void Run()
{
//...
Console.WriteLine("Boolean switch {0} configured as {1}",
boolSwitch.DisplayName, boolSwitch.Enabled.ToString());
if (boolSwitch.Enabled)
Console.WriteLine($"Boolean switch {s_boolSwitch.DisplayName} configured as {s_boolSwitch.Enabled}");
if (s_boolSwitch.Enabled)
{
//...
}
Expand Down
Loading
Loading