(
+ (request, token) => request.PageToken = token,
+ response => response.NextPageToken,
+ response => response.Items);
+ ]]>
+ (
+ (request, token) => request.PageToken = token,
+ response => response.NextPageToken,
+ response => response.Items);
+ ]]>
+ (
+ (request, token) => request.PageToken = token,
+ response => response.NextPageToken,
+ response => response.Items);
+ ]]>
+
+ // dotnet run key1=value1 --key2=value2 /key3=value3 --key4 value4 /key5 value5
+
+ using Microsoft.Extensions.Configuration;
+ using System;
+
+ namespace CommandLineSample
+ {
+ public class Program
+ {
+ public static void Main(string[] args)
+ {
+ var builder = new ConfigurationBuilder();
+ builder.AddCommandLine(args);
+
+ var config = builder.Build();
+
+ Console.WriteLine($"Key1: '{config["Key1"]}'");
+ Console.WriteLine($"Key2: '{config["Key2"]}'");
+ Console.WriteLine($"Key3: '{config["Key3"]}'");
+ Console.WriteLine($"Key4: '{config["Key4"]}'");
+ Console.WriteLine($"Key5: '{config["Key5"]}'");
+ }
+ }
+ }
+
+
+ // dotnet run -k1=value1 -k2 value2 --alt3=value2 /alt4=value3 --alt5 value5 /alt6 value6
+
+ using Microsoft.Extensions.Configuration;
+ using System;
+ using System.Collections.Generic;
+
+ namespace CommandLineSample
+ {
+ public class Program
+ {
+ public static void Main(string[] args)
+ {
+ var switchMappings = new Dictionary<string, string>()
+ {
+ { "-k1", "key1" },
+ { "-k2", "key2" },
+ { "--alt3", "key3" },
+ { "--alt4", "key4" },
+ { "--alt5", "key5" },
+ { "--alt6", "key6" },
+ };
+ var builder = new ConfigurationBuilder();
+ builder.AddCommandLine(args, switchMappings);
+
+ var config = builder.Build();
+
+ Console.WriteLine($"Key1: '{config["Key1"]}'");
+ Console.WriteLine($"Key2: '{config["Key2"]}'");
+ Console.WriteLine($"Key3: '{config["Key3"]}'");
+ Console.WriteLine($"Key4: '{config["Key4"]}'");
+ Console.WriteLine($"Key5: '{config["Key5"]}'");
+ Console.WriteLine($"Key6: '{config["Key6"]}'");
+ }
+ }
+ }
+
+
+ // dotnet run key1=value1 --key2=value2 /key3=value3 --key4 value4 /key5 value5
+
+ using Microsoft.Extensions.Configuration;
+ using System;
+
+ namespace CommandLineSample
+ {
+ public class Program
+ {
+ public static void Main(string[] args)
+ {
+ var builder = new ConfigurationBuilder();
+ builder.AddCommandLine(args);
+
+ var config = builder.Build();
+
+ Console.WriteLine($"Key1: '{config["Key1"]}'");
+ Console.WriteLine($"Key2: '{config["Key2"]}'");
+ Console.WriteLine($"Key3: '{config["Key3"]}'");
+ Console.WriteLine($"Key4: '{config["Key4"]}'");
+ Console.WriteLine($"Key5: '{config["Key5"]}'");
+ }
+ }
+ }
+
+
+ // dotnet run -k1=value1 -k2 value2 --alt3=value2 /alt4=value3 --alt5 value5 /alt6 value6
+
+ using Microsoft.Extensions.Configuration;
+ using System;
+ using System.Collections.Generic;
+
+ namespace CommandLineSample
+ {
+ public class Program
+ {
+ public static void Main(string[] args)
+ {
+ var switchMappings = new Dictionary<string, string>()
+ {
+ { "-k1", "key1" },
+ { "-k2", "key2" },
+ { "--alt3", "key3" },
+ { "--alt4", "key4" },
+ { "--alt5", "key5" },
+ { "--alt6", "key6" },
+ };
+ var builder = new ConfigurationBuilder();
+ builder.AddCommandLine(args, switchMappings);
+
+ var config = builder.Build();
+
+ Console.WriteLine($"Key1: '{config["Key1"]}'");
+ Console.WriteLine($"Key2: '{config["Key2"]}'");
+ Console.WriteLine($"Key3: '{config["Key3"]}'");
+ Console.WriteLine($"Key4: '{config["Key4"]}'");
+ Console.WriteLine($"Key5: '{config["Key5"]}'");
+ Console.WriteLine($"Key6: '{config["Key6"]}'");
+ }
+ }
+ }
+
+
+ // dotnet run key1=value1 --key2=value2 /key3=value3 --key4 value4 /key5 value5
+
+ using Microsoft.Extensions.Configuration;
+ using System;
+
+ namespace CommandLineSample
+ {
+ public class Program
+ {
+ public static void Main(string[] args)
+ {
+ var builder = new ConfigurationBuilder();
+ builder.AddCommandLine(args);
+
+ var config = builder.Build();
+
+ Console.WriteLine($"Key1: '{config["Key1"]}'");
+ Console.WriteLine($"Key2: '{config["Key2"]}'");
+ Console.WriteLine($"Key3: '{config["Key3"]}'");
+ Console.WriteLine($"Key4: '{config["Key4"]}'");
+ Console.WriteLine($"Key5: '{config["Key5"]}'");
+ }
+ }
+ }
+
+
+ // dotnet run -k1=value1 -k2 value2 --alt3=value2 /alt4=value3 --alt5 value5 /alt6 value6
+
+ using Microsoft.Extensions.Configuration;
+ using System;
+ using System.Collections.Generic;
+
+ namespace CommandLineSample
+ {
+ public class Program
+ {
+ public static void Main(string[] args)
+ {
+ var switchMappings = new Dictionary<string, string>()
+ {
+ { "-k1", "key1" },
+ { "-k2", "key2" },
+ { "--alt3", "key3" },
+ { "--alt4", "key4" },
+ { "--alt5", "key5" },
+ { "--alt6", "key6" },
+ };
+ var builder = new ConfigurationBuilder();
+ builder.AddCommandLine(args, switchMappings);
+
+ var config = builder.Build();
+
+ Console.WriteLine($"Key1: '{config["Key1"]}'");
+ Console.WriteLine($"Key2: '{config["Key2"]}'");
+ Console.WriteLine($"Key3: '{config["Key3"]}'");
+ Console.WriteLine($"Key4: '{config["Key4"]}'");
+ Console.WriteLine($"Key5: '{config["Key5"]}'");
+ Console.WriteLine($"Key6: '{config["Key6"]}'");
+ }
+ }
+ }
+
+
+ // dotnet run key1=value1 --key2=value2 /key3=value3 --key4 value4 /key5 value5
+
+ using Microsoft.Extensions.Configuration;
+ using System;
+
+ namespace CommandLineSample
+ {
+ public class Program
+ {
+ public static void Main(string[] args)
+ {
+ var builder = new ConfigurationBuilder();
+ builder.AddCommandLine(args);
+
+ var config = builder.Build();
+
+ Console.WriteLine($"Key1: '{config["Key1"]}'");
+ Console.WriteLine($"Key2: '{config["Key2"]}'");
+ Console.WriteLine($"Key3: '{config["Key3"]}'");
+ Console.WriteLine($"Key4: '{config["Key4"]}'");
+ Console.WriteLine($"Key5: '{config["Key5"]}'");
+ }
+ }
+ }
+
+
+ // dotnet run -k1=value1 -k2 value2 --alt3=value2 /alt4=value3 --alt5 value5 /alt6 value6
+
+ using Microsoft.Extensions.Configuration;
+ using System;
+ using System.Collections.Generic;
+
+ namespace CommandLineSample
+ {
+ public class Program
+ {
+ public static void Main(string[] args)
+ {
+ var switchMappings = new Dictionary<string, string>()
+ {
+ { "-k1", "key1" },
+ { "-k2", "key2" },
+ { "--alt3", "key3" },
+ { "--alt4", "key4" },
+ { "--alt5", "key5" },
+ { "--alt6", "key6" },
+ };
+ var builder = new ConfigurationBuilder();
+ builder.AddCommandLine(args, switchMappings);
+
+ var config = builder.Build();
+
+ Console.WriteLine($"Key1: '{config["Key1"]}'");
+ Console.WriteLine($"Key2: '{config["Key2"]}'");
+ Console.WriteLine($"Key3: '{config["Key3"]}'");
+ Console.WriteLine($"Key4: '{config["Key4"]}'");
+ Console.WriteLine($"Key5: '{config["Key5"]}'");
+ Console.WriteLine($"Key6: '{config["Key6"]}'");
+ }
+ }
+ }
+
+
+ // dotnet run key1=value1 --key2=value2 /key3=value3 --key4 value4 /key5 value5
+
+ using Microsoft.Extensions.Configuration;
+ using System;
+
+ namespace CommandLineSample
+ {
+ public class Program
+ {
+ public static void Main(string[] args)
+ {
+ var builder = new ConfigurationBuilder();
+ builder.AddCommandLine(args);
+
+ var config = builder.Build();
+
+ Console.WriteLine($"Key1: '{config["Key1"]}'");
+ Console.WriteLine($"Key2: '{config["Key2"]}'");
+ Console.WriteLine($"Key3: '{config["Key3"]}'");
+ Console.WriteLine($"Key4: '{config["Key4"]}'");
+ Console.WriteLine($"Key5: '{config["Key5"]}'");
+ }
+ }
+ }
+
+
+ // dotnet run -k1=value1 -k2 value2 --alt3=value2 /alt4=value3 --alt5 value5 /alt6 value6
+
+ using Microsoft.Extensions.Configuration;
+ using System;
+ using System.Collections.Generic;
+
+ namespace CommandLineSample
+ {
+ public class Program
+ {
+ public static void Main(string[] args)
+ {
+ var switchMappings = new Dictionary<string, string>()
+ {
+ { "-k1", "key1" },
+ { "-k2", "key2" },
+ { "--alt3", "key3" },
+ { "--alt4", "key4" },
+ { "--alt5", "key5" },
+ { "--alt6", "key6" },
+ };
+ var builder = new ConfigurationBuilder();
+ builder.AddCommandLine(args, switchMappings);
+
+ var config = builder.Build();
+
+ Console.WriteLine($"Key1: '{config["Key1"]}'");
+ Console.WriteLine($"Key2: '{config["Key2"]}'");
+ Console.WriteLine($"Key3: '{config["Key3"]}'");
+ Console.WriteLine($"Key4: '{config["Key4"]}'");
+ Console.WriteLine($"Key5: '{config["Key5"]}'");
+ Console.WriteLine($"Key6: '{config["Key6"]}'");
+ }
+ }
+ }
+
+
+ class MyEventListener : EventListener {
+ protected override void OnEventSourceCreated(EventSource eventSource) {
+ if (eventSource.Name == "Microsoft-Extensions-Logging") {
+ // Initialize a dictionary of arguments to pass to the EventSource.
+ // Turn on loggers matching App* to Information; everything else (*) is the default level (which is EventLevel.Error).
+ var args = new Dictionary<string, string>() { { "FilterSpecs", "App*:Information;*" } };
+ // Set the default level (verbosity) to Error, and only ask for the formatted messages in this case.
+ EnableEvents(eventSource, EventLevel.Error, LoggingEventSource.Keywords.FormattedMessage, args);
+ }
+ }
+ protected override void OnEventWritten(EventWrittenEventArgs eventData) {
+ // Look for the formatted message event, which has the following argument layout (as defined in the LoggingEventSource):
+ // FormattedMessage(LogLevel Level, int FactoryID, string LoggerName, string EventId, string FormattedMessage);
+ if (eventData.EventName == "FormattedMessage")
+ Console.WriteLine($"Logger {eventData.Payload[2]}: {eventData.Payload[4]}");
+ }
+ }
+
+
+ class MyEventListener : EventListener {
+ protected override void OnEventSourceCreated(EventSource eventSource) {
+ if (eventSource.Name == "Microsoft-Extensions-Logging") {
+ // Initialize a dictionary of arguments to pass to the EventSource.
+ // Turn on loggers matching App* to Information; everything else (*) is the default level (which is EventLevel.Error).
+ var args = new Dictionary<string, string>() { { "FilterSpecs", "App*:Information;*" } };
+ // Set the default level (verbosity) to Error, and only ask for the formatted messages in this case.
+ EnableEvents(eventSource, EventLevel.Error, LoggingEventSource.Keywords.FormattedMessage, args);
+ }
+ }
+ protected override void OnEventWritten(EventWrittenEventArgs eventData) {
+ // Look for the formatted message event, which has the following argument layout (as defined in the LoggingEventSource):
+ // FormattedMessage(LogLevel Level, int FactoryID, string LoggerName, string EventId, string FormattedMessage);
+ if (eventData.EventName == "FormattedMessage")
+ Console.WriteLine($"Logger {eventData.Payload[2]}: {eventData.Payload[4]}");
+ }
+ }
+
+
+ class MyEventListener : EventListener {
+ protected override void OnEventSourceCreated(EventSource eventSource) {
+ if (eventSource.Name == "Microsoft-Extensions-Logging") {
+ // Initialize a dictionary of arguments to pass to the EventSource.
+ // Turn on loggers matching App* to Information; everything else (*) is the default level (which is EventLevel.Error).
+ var args = new Dictionary<string, string>() { { "FilterSpecs", "App*:Information;*" } };
+ // Set the default level (verbosity) to Error, and only ask for the formatted messages in this case.
+ EnableEvents(eventSource, EventLevel.Error, LoggingEventSource.Keywords.FormattedMessage, args);
+ }
+ }
+ protected override void OnEventWritten(EventWrittenEventArgs eventData) {
+ // Look for the formatted message event, which has the following argument layout (as defined in the LoggingEventSource):
+ // FormattedMessage(LogLevel Level, int FactoryID, string LoggerName, string EventId, string FormattedMessage);
+ if (eventData.EventName == "FormattedMessage")
+ Console.WriteLine($"Logger {eventData.Payload[2]}: {eventData.Payload[4]}");
+ }
+ }
+
+
+ class MyEventListener : EventListener {
+ protected override void OnEventSourceCreated(EventSource eventSource) {
+ if (eventSource.Name == "Microsoft-Extensions-Logging") {
+ // Initialize a dictionary of arguments to pass to the EventSource.
+ // Turn on loggers matching App* to Information; everything else (*) is the default level (which is EventLevel.Error).
+ var args = new Dictionary<string, string>() { { "FilterSpecs", "App*:Information;*" } };
+ // Set the default level (verbosity) to Error, and only ask for the formatted messages in this case.
+ EnableEvents(eventSource, EventLevel.Error, LoggingEventSource.Keywords.FormattedMessage, args);
+ }
+ }
+ protected override void OnEventWritten(EventWrittenEventArgs eventData) {
+ // Look for the formatted message event, which has the following argument layout (as defined in the LoggingEventSource):
+ // FormattedMessage(LogLevel Level, int FactoryID, string LoggerName, string EventId, string FormattedMessage);
+ if (eventData.EventName == "FormattedMessage")
+ Console.WriteLine($"Logger {eventData.Payload[2]}: {eventData.Payload[4]}");
+ }
+ }
+
+
+ class MyEventListener : EventListener {
+ protected override void OnEventSourceCreated(EventSource eventSource) {
+ if (eventSource.Name == "Microsoft-Extensions-Logging") {
+ // Initialize a dictionary of arguments to pass to the EventSource.
+ // Turn on loggers matching App* to Information; everything else (*) is the default level (which is EventLevel.Error).
+ var args = new Dictionary<string, string>() { { "FilterSpecs", "App*:Information;*" } };
+ // Set the default level (verbosity) to Error, and only ask for the formatted messages in this case.
+ EnableEvents(eventSource, EventLevel.Error, LoggingEventSource.Keywords.FormattedMessage, args);
+ }
+ }
+ protected override void OnEventWritten(EventWrittenEventArgs eventData) {
+ // Look for the formatted message event, which has the following argument layout (as defined in the LoggingEventSource):
+ // FormattedMessage(LogLevel Level, int FactoryID, string LoggerName, string EventId, string FormattedMessage);
+ if (eventData.EventName == "FormattedMessage")
+ Console.WriteLine($"Logger {eventData.Payload[2]}: {eventData.Payload[4]}");
+ }
+ }
+
+
+ Throws.IfNullOrMemberNull(myObject, myObject?.MyProperty)
+
+
+ Throws.IfMemberNull(myObject, myObject.MyProperty)
+
+
+ Throws.IfNullOrMemberNull(myObject, myObject?.MyProperty)
+
+
+ Throws.IfMemberNull(myObject, myObject.MyProperty)
+
+
+ Throws.IfNullOrMemberNull(myObject, myObject?.MyProperty)
+
+
+ Throws.IfMemberNull(myObject, myObject.MyProperty)
+
+ ^[A-Za-z0-9-_]+\\.[A-Za-z0-9-_]+\\.[A-Za-z0-9-_]*$RegexOptions.CultureInvariant
+ ○ Match if at the beginning of the string.
+ ○ Match a character in the set [-0-9A-Z_a-z] atomically at least once.
+ ○ Match '.'.
+ ○ Match a character in the set [-0-9A-Z_a-z] atomically at least once.
+ ○ Match '.'.
+ ○ Match a character in the set [-0-9A-Z_a-z] atomically any number of times.
+ ○ Match if at the end of the string or if before an ending newline.
+
+ ^[A-Za-z0-9-_]+\\.[A-Za-z0-9-_]*\\.[A-Za-z0-9-_]+\\.[A-Za-z0-9-_]+\\.[A-Za-z0-9-_]+$RegexOptions.CultureInvariant
+ ○ Match if at the beginning of the string.
+ ○ Match a character in the set [-0-9A-Z_a-z] atomically at least once.
+ ○ Match '.'.
+ ○ Match a character in the set [-0-9A-Z_a-z] atomically any number of times.
+ ○ Match '.'.
+ ○ Match a character in the set [-0-9A-Z_a-z] atomically at least once.
+ ○ Match '.'.
+ ○ Match a character in the set [-0-9A-Z_a-z] atomically at least once.
+ ○ Match '.'.
+ ○ Match a character in the set [-0-9A-Z_a-z] atomically at least once.
+ ○ Match if at the end of the string or if before an ending newline.
+
+ "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}".
+ An object that will be used to `lock` (sync) access to the console output. If you specify this, you
+ will have the ability to lock on this object, and guarantee that the console sink will not be about to output anything while
+ the lock is held.
+ Supplies culture-specific formatting information, or null.
+ A switch allowing the pass-through minimum level
+ to be changed at runtime.
+ Specifies the level at which events will be written to standard error.
+ The theme to apply to the styled output. If not specified,
+ uses nullnullnullnull"[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}".
+ An object that will be used to `lock` (sync) access to the console output. If you specify this, you
+ will have the ability to lock on this object, and guarantee that the console sink will not be about to output anything while
+ the lock is held.
+ Supplies culture-specific formatting information, or null.
+ A switch allowing the pass-through minimum level
+ to be changed at runtime.
+ Specifies the level at which events will be written to standard error.
+ The theme to apply to the styled output. If not specified,
+ uses nullnullnullnullnullnull"[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}".
+ An object that will be used to `lock` (sync) access to the console output. If you specify this, you
+ will have the ability to lock on this object, and guarantee that the console sink will not be about to output anything while
+ the lock is held.
+ Supplies culture-specific formatting information, or null.
+ A switch allowing the pass-through minimum level
+ to be changed at runtime.
+ Specifies the level at which events will be written to standard error.
+ The theme to apply to the styled output. If not specified,
+ uses nullnullnullnull"[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}".
+ An object that will be used to `lock` (sync) access to the console output. If you specify this, you
+ will have the ability to lock on this object, and guarantee that the console sink will not be about to output anything while
+ the lock is held.
+ Supplies culture-specific formatting information, or null.
+ A switch allowing the pass-through minimum level
+ to be changed at runtime.
+ Specifies the level at which events will be written to standard error.
+ The theme to apply to the styled output. If not specified,
+ uses nullnullnullnullnullnull"[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}".
+ An object that will be used to `lock` (sync) access to the console output. If you specify this, you
+ will have the ability to lock on this object, and guarantee that the console sink will not be about to output anything while
+ the lock is held.
+ Supplies culture-specific formatting information, or null.
+ A switch allowing the pass-through minimum level
+ to be changed at runtime.
+ Specifies the level at which events will be written to standard error.
+ The theme to apply to the styled output. If not specified,
+ uses nullnullnullnull"[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}".
+ An object that will be used to `lock` (sync) access to the console output. If you specify this, you
+ will have the ability to lock on this object, and guarantee that the console sink will not be about to output anything while
+ the lock is held.
+ Supplies culture-specific formatting information, or null.
+ A switch allowing the pass-through minimum level
+ to be changed at runtime.
+ Specifies the level at which events will be written to standard error.
+ The theme to apply to the styled output. If not specified,
+ uses nullnullnullnullnullnull"[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}".
+ An object that will be used to `lock` (sync) access to the console output. If you specify this, you
+ will have the ability to lock on this object, and guarantee that the console sink will not be about to output anything while
+ the lock is held.
+ Supplies culture-specific formatting information, or null.
+ A switch allowing the pass-through minimum level
+ to be changed at runtime.
+ Specifies the level at which events will be written to standard error.
+ The theme to apply to the styled output. If not specified,
+ uses nullnullnullnull"[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}".
+ An object that will be used to `lock` (sync) access to the console output. If you specify this, you
+ will have the ability to lock on this object, and guarantee that the console sink will not be about to output anything while
+ the lock is held.
+ Supplies culture-specific formatting information, or null.
+ A switch allowing the pass-through minimum level
+ to be changed at runtime.
+ Specifies the level at which events will be written to standard error.
+ The theme to apply to the styled output. If not specified,
+ uses nullnullnullnullnullnull"[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}".
+ An object that will be used to `lock` (sync) access to the console output. If you specify this, you
+ will have the ability to lock on this object, and guarantee that the console sink will not be about to output anything while
+ the lock is held.
+ Supplies culture-specific formatting information, or null.
+ A switch allowing the pass-through minimum level
+ to be changed at runtime.
+ Specifies the level at which events will be written to standard error.
+ The theme to apply to the styled output. If not specified,
+ uses nullnullnullnull"[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}".
+ An object that will be used to `lock` (sync) access to the console output. If you specify this, you
+ will have the ability to lock on this object, and guarantee that the console sink will not be about to output anything while
+ the lock is held.
+ Supplies culture-specific formatting information, or null.
+ A switch allowing the pass-through minimum level
+ to be changed at runtime.
+ Specifies the level at which events will be written to standard error.
+ The theme to apply to the styled output. If not specified,
+ uses nullnullnullnullnullnull"[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}".
+ An object that will be used to `lock` (sync) access to the console output. If you specify this, you
+ will have the ability to lock on this object, and guarantee that the console sink will not be about to output anything while
+ the lock is held.
+ Supplies culture-specific formatting information, or null.
+ A switch allowing the pass-through minimum level
+ to be changed at runtime.
+ Specifies the level at which events will be written to standard error.
+ The theme to apply to the styled output. If not specified,
+ uses nullnullnullnull"[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}".
+ An object that will be used to `lock` (sync) access to the console output. If you specify this, you
+ will have the ability to lock on this object, and guarantee that the console sink will not be about to output anything while
+ the lock is held.
+ Supplies culture-specific formatting information, or null.
+ A switch allowing the pass-through minimum level
+ to be changed at runtime.
+ Specifies the level at which events will be written to standard error.
+ The theme to apply to the styled output. If not specified,
+ uses nullnullnullnullnullnull"[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}".
+ An object that will be used to `lock` (sync) access to the console output. If you specify this, you
+ will have the ability to lock on this object, and guarantee that the console sink will not be about to output anything while
+ the lock is held.
+ Supplies culture-specific formatting information, or null.
+ A switch allowing the pass-through minimum level
+ to be changed at runtime.
+ Specifies the level at which events will be written to standard error.
+ The theme to apply to the styled output. If not specified,
+ uses nullnullnullnull"[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}".
+ An object that will be used to `lock` (sync) access to the console output. If you specify this, you
+ will have the ability to lock on this object, and guarantee that the console sink will not be about to output anything while
+ the lock is held.
+ Supplies culture-specific formatting information, or null.
+ A switch allowing the pass-through minimum level
+ to be changed at runtime.
+ Specifies the level at which events will be written to standard error.
+ The theme to apply to the styled output. If not specified,
+ uses nullnullnullnullnullnull
+ [CanBeNull] object Test() => null;
+
+ void UseTest() {
+ var p = Test();
+ var s = p.ToString(); // Warning: Possible 'System.NullReferenceException'
+ }
+
+ [NotNull] object Foo() {
+ return null; // Warning: Possible 'null' assignment
+ }
+
+ [StringFormatMethod("message")]
+ void ShowError(string message, params object[] args) { /* do something */ }
+
+ void Foo() {
+ ShowError("Failed: {0}"); // Warning: Non-existing argument in format string
+ }
+
+ void Foo(string param) {
+ if (param == null)
+ throw new ArgumentNullException("par"); // Warning: Cannot resolve symbol
+ }
+
+ public class Foo : INotifyPropertyChanged {
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ [NotifyPropertyChangedInvocator]
+ protected virtual void NotifyChanged(string propertyName) { ... }
+
+ string _name;
+
+ public string Name {
+ get { return _name; }
+ set { _name = value; NotifyChanged("LastName"); /* Warning */ }
+ }
+ }
+
+ Examples of generated notifications:
+ Function Definition Table syntax:
+
+ [ContractAnnotation("=> halt")]
+ public void TerminationMethod()
+
+ [ContractAnnotation("halt <= condition: false")]
+ public void Assert(bool condition, string text) // regular assertion method
+
+ [ContractAnnotation("s:null => true")]
+ public bool IsNullOrEmpty(string s) // string.IsNullOrEmpty()
+
+ // A method that returns null if the parameter is null,
+ // and not null if the parameter is not null
+ [ContractAnnotation("null => null; notnull => notnull")]
+ public object Transform(object data)
+
+ [ContractAnnotation("=> true, result: notnull; => false, result: null")]
+ public bool TryParse(string s, out Person result)
+
+ [LocalizationRequiredAttribute(true)]
+ class Foo {
+ string str = "my string"; // Warning: Localizable string
+ }
+
+ [CannotApplyEqualityOperator]
+ class NoEquality { }
+
+ class UsesNoEquality {
+ void Test() {
+ var ca1 = new NoEquality();
+ var ca2 = new NoEquality();
+ if (ca1 != null) { // OK
+ bool condition = ca1 == ca2; // Warning
+ }
+ }
+ }
+
+ [BaseTypeRequired(typeof(IComponent)] // Specify requirement
+ class ComponentAttribute : Attribute { }
+
+ [Component] // ComponentAttribute requires implementing IComponent interface
+ class MyComponent : IComponent { }
+
+ [Pure] int Multiply(int x, int y) => x * y;
+
+ void M() {
+ Multiply(123, 42); // Waring: Return value of pure method is not used
+ }
+
+ class Foo {
+ [ProvidesContext] IBarService _barService = ...;
+
+ void ProcessNode(INode node) {
+ DoSomething(node, node.GetGlobalServices().Bar);
+ // ^ Warning: use value of '_barService' field
+ }
+ }
+
+ [SourceTemplate]
+ public static void forEach<T>(this IEnumerable<T> xs) {
+ foreach (var x in xs) {
+ //$ $END$
+ }
+ }
+
+
+ [SourceTemplate, Macro(Target = "item", Expression = "suggestVariableName()")]
+ public static void forEach<T>(this IEnumerable<T> collection) {
+ foreach (var item in collection) {
+ //$ $END$
+ }
+ }
+
+ Applying the attribute on a template method parameter:
+
+ [SourceTemplate]
+ public static void something(this Entity x, [Macro(Expression = "guid()", Editable = -1)] string newguid) {
+ /*$ var $x$Id = "$newguid$" + x.ToString();
+ x.DoSomething($x$Id); */
+ }
+
+
+ [ActionName("Foo")]
+ public ActionResult Login(string returnUrl) {
+ ViewBag.ReturnUrl = Url.Action("Foo"); // OK
+ return RedirectToAction("Bar"); // Error: Cannot resolve action
+ }
+
+ [CanBeNull] object Test() => null;
+
+ void UseTest() {
+ var p = Test();
+ var s = p.ToString(); // Warning: Possible 'System.NullReferenceException'
+ }
+
+ [NotNull] object Foo() {
+ return null; // Warning: Possible 'null' assignment
+ }
+
+ [StringFormatMethod("message")]
+ void ShowError(string message, params object[] args) { /* do something */ }
+
+ void Foo() {
+ ShowError("Failed: {0}"); // Warning: Non-existing argument in format string
+ }
+
+ void Foo(string param) {
+ if (param == null)
+ throw new ArgumentNullException("par"); // Warning: Cannot resolve symbol
+ }
+
+ public class Foo : INotifyPropertyChanged {
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ [NotifyPropertyChangedInvocator]
+ protected virtual void NotifyChanged(string propertyName) { ... }
+
+ string _name;
+
+ public string Name {
+ get { return _name; }
+ set { _name = value; NotifyChanged("LastName"); /* Warning */ }
+ }
+ }
+
+ Examples of generated notifications:
+ Function Definition Table syntax:
+
+ [ContractAnnotation("=> halt")]
+ public void TerminationMethod()
+
+ [ContractAnnotation("halt <= condition: false")]
+ public void Assert(bool condition, string text) // regular assertion method
+
+ [ContractAnnotation("s:null => true")]
+ public bool IsNullOrEmpty(string s) // string.IsNullOrEmpty()
+
+ // A method that returns null if the parameter is null,
+ // and not null if the parameter is not null
+ [ContractAnnotation("null => null; notnull => notnull")]
+ public object Transform(object data)
+
+ [ContractAnnotation("=> true, result: notnull; => false, result: null")]
+ public bool TryParse(string s, out Person result)
+
+ [LocalizationRequiredAttribute(true)]
+ class Foo {
+ string str = "my string"; // Warning: Localizable string
+ }
+
+ [CannotApplyEqualityOperator]
+ class NoEquality { }
+
+ class UsesNoEquality {
+ void Test() {
+ var ca1 = new NoEquality();
+ var ca2 = new NoEquality();
+ if (ca1 != null) { // OK
+ bool condition = ca1 == ca2; // Warning
+ }
+ }
+ }
+
+ [BaseTypeRequired(typeof(IComponent)] // Specify requirement
+ class ComponentAttribute : Attribute { }
+
+ [Component] // ComponentAttribute requires implementing IComponent interface
+ class MyComponent : IComponent { }
+
+ [Pure] int Multiply(int x, int y) => x * y;
+
+ void M() {
+ Multiply(123, 42); // Waring: Return value of pure method is not used
+ }
+
+ class Foo {
+ [ProvidesContext] IBarService _barService = ...;
+
+ void ProcessNode(INode node) {
+ DoSomething(node, node.GetGlobalServices().Bar);
+ // ^ Warning: use value of '_barService' field
+ }
+ }
+
+ [SourceTemplate]
+ public static void forEach<T>(this IEnumerable<T> xs) {
+ foreach (var x in xs) {
+ //$ $END$
+ }
+ }
+
+
+ [SourceTemplate, Macro(Target = "item", Expression = "suggestVariableName()")]
+ public static void forEach<T>(this IEnumerable<T> collection) {
+ foreach (var item in collection) {
+ //$ $END$
+ }
+ }
+
+ Applying the attribute on a template method parameter:
+
+ [SourceTemplate]
+ public static void something(this Entity x, [Macro(Expression = "guid()", Editable = -1)] string newguid) {
+ /*$ var $x$Id = "$newguid$" + x.ToString();
+ x.DoSomething($x$Id); */
+ }
+
+
+ [ActionName("Foo")]
+ public ActionResult Login(string returnUrl) {
+ ViewBag.ReturnUrl = Url.Action("Foo"); // OK
+ return RedirectToAction("Bar"); // Error: Cannot resolve action
+ }
+
+ [CanBeNull] object Test() => null;
+
+ void UseTest() {
+ var p = Test();
+ var s = p.ToString(); // Warning: Possible 'System.NullReferenceException'
+ }
+
+ [NotNull] object Foo() {
+ return null; // Warning: Possible 'null' assignment
+ }
+
+ [StringFormatMethod("message")]
+ void ShowError(string message, params object[] args) { /* do something */ }
+
+ void Foo() {
+ ShowError("Failed: {0}"); // Warning: Non-existing argument in format string
+ }
+
+ void Foo(string param) {
+ if (param == null)
+ throw new ArgumentNullException("par"); // Warning: Cannot resolve symbol
+ }
+
+ public class Foo : INotifyPropertyChanged {
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ [NotifyPropertyChangedInvocator]
+ protected virtual void NotifyChanged(string propertyName) { ... }
+
+ string _name;
+
+ public string Name {
+ get { return _name; }
+ set { _name = value; NotifyChanged("LastName"); /* Warning */ }
+ }
+ }
+
+ Examples of generated notifications:
+ Function Definition Table syntax:
+
+ [ContractAnnotation("=> halt")]
+ public void TerminationMethod()
+
+ [ContractAnnotation("halt <= condition: false")]
+ public void Assert(bool condition, string text) // regular assertion method
+
+ [ContractAnnotation("s:null => true")]
+ public bool IsNullOrEmpty(string s) // string.IsNullOrEmpty()
+
+ // A method that returns null if the parameter is null,
+ // and not null if the parameter is not null
+ [ContractAnnotation("null => null; notnull => notnull")]
+ public object Transform(object data)
+
+ [ContractAnnotation("=> true, result: notnull; => false, result: null")]
+ public bool TryParse(string s, out Person result)
+
+ [LocalizationRequiredAttribute(true)]
+ class Foo {
+ string str = "my string"; // Warning: Localizable string
+ }
+
+ [CannotApplyEqualityOperator]
+ class NoEquality { }
+
+ class UsesNoEquality {
+ void Test() {
+ var ca1 = new NoEquality();
+ var ca2 = new NoEquality();
+ if (ca1 != null) { // OK
+ bool condition = ca1 == ca2; // Warning
+ }
+ }
+ }
+
+ [BaseTypeRequired(typeof(IComponent)] // Specify requirement
+ class ComponentAttribute : Attribute { }
+
+ [Component] // ComponentAttribute requires implementing IComponent interface
+ class MyComponent : IComponent { }
+
+ [Pure] int Multiply(int x, int y) => x * y;
+
+ void M() {
+ Multiply(123, 42); // Waring: Return value of pure method is not used
+ }
+
+ class Foo {
+ [ProvidesContext] IBarService _barService = ...;
+
+ void ProcessNode(INode node) {
+ DoSomething(node, node.GetGlobalServices().Bar);
+ // ^ Warning: use value of '_barService' field
+ }
+ }
+
+ [SourceTemplate]
+ public static void forEach<T>(this IEnumerable<T> xs) {
+ foreach (var x in xs) {
+ //$ $END$
+ }
+ }
+
+
+ [SourceTemplate, Macro(Target = "item", Expression = "suggestVariableName()")]
+ public static void forEach<T>(this IEnumerable<T> collection) {
+ foreach (var item in collection) {
+ //$ $END$
+ }
+ }
+
+ Applying the attribute on a template method parameter:
+
+ [SourceTemplate]
+ public static void something(this Entity x, [Macro(Expression = "guid()", Editable = -1)] string newguid) {
+ /*$ var $x$Id = "$newguid$" + x.ToString();
+ x.DoSomething($x$Id); */
+ }
+
+
+ [ActionName("Foo")]
+ public ActionResult Login(string returnUrl) {
+ ViewBag.ReturnUrl = Url.Action("Foo"); // OK
+ return RedirectToAction("Bar"); // Error: Cannot resolve action
+ }
+
+ [CanBeNull] object Test() => null;
+
+ void UseTest() {
+ var p = Test();
+ var s = p.ToString(); // Warning: Possible 'System.NullReferenceException'
+ }
+
+ [NotNull] object Foo() {
+ return null; // Warning: Possible 'null' assignment
+ }
+
+ [StringFormatMethod("message")]
+ void ShowError(string message, params object[] args) { /* do something */ }
+
+ void Foo() {
+ ShowError("Failed: {0}"); // Warning: Non-existing argument in format string
+ }
+
+ void Foo(string param) {
+ if (param == null)
+ throw new ArgumentNullException("par"); // Warning: Cannot resolve symbol
+ }
+
+ public class Foo : INotifyPropertyChanged {
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ [NotifyPropertyChangedInvocator]
+ protected virtual void NotifyChanged(string propertyName) { ... }
+
+ string _name;
+
+ public string Name {
+ get { return _name; }
+ set { _name = value; NotifyChanged("LastName"); /* Warning */ }
+ }
+ }
+
+ Examples of generated notifications:
+ Function Definition Table syntax:
+
+ [ContractAnnotation("=> halt")]
+ public void TerminationMethod()
+
+ [ContractAnnotation("halt <= condition: false")]
+ public void Assert(bool condition, string text) // regular assertion method
+
+ [ContractAnnotation("s:null => true")]
+ public bool IsNullOrEmpty(string s) // string.IsNullOrEmpty()
+
+ // A method that returns null if the parameter is null,
+ // and not null if the parameter is not null
+ [ContractAnnotation("null => null; notnull => notnull")]
+ public object Transform(object data)
+
+ [ContractAnnotation("=> true, result: notnull; => false, result: null")]
+ public bool TryParse(string s, out Person result)
+
+ [LocalizationRequiredAttribute(true)]
+ class Foo {
+ string str = "my string"; // Warning: Localizable string
+ }
+
+ [CannotApplyEqualityOperator]
+ class NoEquality { }
+
+ class UsesNoEquality {
+ void Test() {
+ var ca1 = new NoEquality();
+ var ca2 = new NoEquality();
+ if (ca1 != null) { // OK
+ bool condition = ca1 == ca2; // Warning
+ }
+ }
+ }
+
+ [BaseTypeRequired(typeof(IComponent)] // Specify requirement
+ class ComponentAttribute : Attribute { }
+
+ [Component] // ComponentAttribute requires implementing IComponent interface
+ class MyComponent : IComponent { }
+
+ [Pure] int Multiply(int x, int y) => x * y;
+
+ void M() {
+ Multiply(123, 42); // Waring: Return value of pure method is not used
+ }
+
+ class Foo {
+ [ProvidesContext] IBarService _barService = ...;
+
+ void ProcessNode(INode node) {
+ DoSomething(node, node.GetGlobalServices().Bar);
+ // ^ Warning: use value of '_barService' field
+ }
+ }
+
+ [SourceTemplate]
+ public static void forEach<T>(this IEnumerable<T> xs) {
+ foreach (var x in xs) {
+ //$ $END$
+ }
+ }
+
+
+ [SourceTemplate, Macro(Target = "item", Expression = "suggestVariableName()")]
+ public static void forEach<T>(this IEnumerable<T> collection) {
+ foreach (var item in collection) {
+ //$ $END$
+ }
+ }
+
+ Applying the attribute on a template method parameter:
+
+ [SourceTemplate]
+ public static void something(this Entity x, [Macro(Expression = "guid()", Editable = -1)] string newguid) {
+ /*$ var $x$Id = "$newguid$" + x.ToString();
+ x.DoSomething($x$Id); */
+ }
+
+
+ [ActionName("Foo")]
+ public ActionResult Login(string returnUrl) {
+ ViewBag.ReturnUrl = Url.Action("Foo"); // OK
+ return RedirectToAction("Bar"); // Error: Cannot resolve action
+ }
+
+ [CanBeNull] object Test() => null;
+
+ void UseTest() {
+ var p = Test();
+ var s = p.ToString(); // Warning: Possible 'System.NullReferenceException'
+ }
+
+ [NotNull] object Foo() {
+ return null; // Warning: Possible 'null' assignment
+ }
+
+ [StringFormatMethod("message")]
+ void ShowError(string message, params object[] args) { /* do something */ }
+
+ void Foo() {
+ ShowError("Failed: {0}"); // Warning: Non-existing argument in format string
+ }
+
+ void Foo(string param) {
+ if (param == null)
+ throw new ArgumentNullException("par"); // Warning: Cannot resolve symbol
+ }
+
+ public class Foo : INotifyPropertyChanged {
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ [NotifyPropertyChangedInvocator]
+ protected virtual void NotifyChanged(string propertyName) { ... }
+
+ string _name;
+
+ public string Name {
+ get { return _name; }
+ set { _name = value; NotifyChanged("LastName"); /* Warning */ }
+ }
+ }
+
+ Examples of generated notifications:
+ Function Definition Table syntax:
+
+ [ContractAnnotation("=> halt")]
+ public void TerminationMethod()
+
+ [ContractAnnotation("halt <= condition: false")]
+ public void Assert(bool condition, string text) // regular assertion method
+
+ [ContractAnnotation("s:null => true")]
+ public bool IsNullOrEmpty(string s) // string.IsNullOrEmpty()
+
+ // A method that returns null if the parameter is null,
+ // and not null if the parameter is not null
+ [ContractAnnotation("null => null; notnull => notnull")]
+ public object Transform(object data)
+
+ [ContractAnnotation("=> true, result: notnull; => false, result: null")]
+ public bool TryParse(string s, out Person result)
+
+ [LocalizationRequiredAttribute(true)]
+ class Foo {
+ string str = "my string"; // Warning: Localizable string
+ }
+
+ [CannotApplyEqualityOperator]
+ class NoEquality { }
+
+ class UsesNoEquality {
+ void Test() {
+ var ca1 = new NoEquality();
+ var ca2 = new NoEquality();
+ if (ca1 != null) { // OK
+ bool condition = ca1 == ca2; // Warning
+ }
+ }
+ }
+
+ [BaseTypeRequired(typeof(IComponent)] // Specify requirement
+ class ComponentAttribute : Attribute { }
+
+ [Component] // ComponentAttribute requires implementing IComponent interface
+ class MyComponent : IComponent { }
+
+ [Pure] int Multiply(int x, int y) => x * y;
+
+ void M() {
+ Multiply(123, 42); // Waring: Return value of pure method is not used
+ }
+
+ class Foo {
+ [ProvidesContext] IBarService _barService = ...;
+
+ void ProcessNode(INode node) {
+ DoSomething(node, node.GetGlobalServices().Bar);
+ // ^ Warning: use value of '_barService' field
+ }
+ }
+
+ [SourceTemplate]
+ public static void forEach<T>(this IEnumerable<T> xs) {
+ foreach (var x in xs) {
+ //$ $END$
+ }
+ }
+
+
+ [SourceTemplate, Macro(Target = "item", Expression = "suggestVariableName()")]
+ public static void forEach<T>(this IEnumerable<T> collection) {
+ foreach (var item in collection) {
+ //$ $END$
+ }
+ }
+
+ Applying the attribute on a template method parameter:
+
+ [SourceTemplate]
+ public static void something(this Entity x, [Macro(Expression = "guid()", Editable = -1)] string newguid) {
+ /*$ var $x$Id = "$newguid$" + x.ToString();
+ x.DoSomething($x$Id); */
+ }
+
+
+ [ActionName("Foo")]
+ public ActionResult Login(string returnUrl) {
+ ViewBag.ReturnUrl = Url.Action("Foo"); // OK
+ return RedirectToAction("Bar"); // Error: Cannot resolve action
+ }
+