提交 8bd2635d 编写于 作者: C Cyrus Najmabadi

Merge remote-tracking branch 'upstream/master' into dateTimeFormat

......@@ -11,22 +11,23 @@ efforts behind them.
| Feature | Branch | State | Developers | Reviewer | LDM Champ |
|----------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------|------------------------------------------------------------------------------|------------------------------------------------------------------------------------|-----------------------------------------|
| [Caller expression attribute](https://github.com/dotnet/csharplang/issues/287) | [caller-expression](https://github.com/dotnet/roslyn/tree/features/caller-expression) | Prototype | [alrz](https://github.com/alrz) | [jcouv](https://github.com/jcouv) | [jcouv](https://github.com/jcouv) |
| [Target-typed new](https://github.com/dotnet/csharplang/issues/100) | [target-typed-new](https://github.com/dotnet/roslyn/tree/features/target-typed-new) | [Merged into 16.7p1](https://github.com/dotnet/roslyn/issues/28489) | [alrz](https://github.com/alrz) | [jcouv](https://github.com/jcouv) | [jcouv](https://github.com/jcouv) |
| [Target-typed new](https://github.com/dotnet/csharplang/issues/100) | [target-typed-new](https://github.com/dotnet/roslyn/tree/features/target-typed-new) | [Merged into 16.7p1](https://github.com/dotnet/roslyn/issues/28489) | [alrz](https://github.com/alrz) | [jcouv](https://github.com/jcouv) | [jcouv](https://github.com/jcouv) |
| [Generic attributes](https://github.com/dotnet/csharplang/issues/124) | [generic-attributes](https://github.com/dotnet/roslyn/tree/features/generic-attributes) | [In Progress](https://github.com/dotnet/roslyn/issues/36285) | [AviAvni](https://github.com/AviAvni) | [agocke](https://github.com/agocke) | [mattwar](https://github.com/mattwar) |
| [Default in deconstruction](https://github.com/dotnet/roslyn/pull/25562) | [decon-default](https://github.com/dotnet/roslyn/tree/features/decon-default) | [Implemented](https://github.com/dotnet/roslyn/issues/25559) | [jcouv](https://github.com/jcouv) | [gafter](https://github.com/gafter) | [jcouv](https://github.com/jcouv) |
| [Relax ordering of `ref` and `partial` modifiers](https://github.com/dotnet/csharplang/issues/946) | [ref-partial](https://github.com/dotnet/roslyn/tree/features/ref-partial) | In Progress | [alrz](https://github.com/alrz) | [gafter](https://github.com/gafter) | [jcouv](https://github.com/jcouv) |
| [Parameter null-checking](https://github.com/dotnet/csharplang/issues/2145) | [param-nullchecking](https://github.com/dotnet/roslyn/tree/features/param-nullchecking) | [In Progress](https://github.com/dotnet/roslyn/issues/36024) | [fayrose](https://github.com/fayrose) | [agocke](https://github.com/agocke) | [jaredpar](https://github.com/jaredpar) |
| [Skip locals init](https://github.com/dotnet/csharplang/issues/1738) | [localsinit](https://github.com/dotnet/roslyn/tree/features/localsinit) | [Merged](https://github.com/dotnet/roslyn/issues/25780) | [t-camaia](https://github.com/t-camaia), [agocke](https://github.com/agocke) | [jaredpar](https://github.com/jaredpar) | [agocke](https://github.com/agocke) |
| [Skip locals init](https://github.com/dotnet/csharplang/issues/1738) | [localsinit](https://github.com/dotnet/roslyn/tree/features/localsinit) | [Merged](https://github.com/dotnet/roslyn/issues/25780) | [t-camaia](https://github.com/t-camaia), [agocke](https://github.com/agocke) | [jaredpar](https://github.com/jaredpar) | [agocke](https://github.com/agocke) |
| [Lambda discard parameters](https://github.com/dotnet/csharplang/issues/111) | master | [Merged](https://github.com/dotnet/roslyn/issues/38820) | [jcouv](https://github.com/jcouv) | [AlekseyTs](https://github.com/AlekseyTs), [chsienki](https://github.com/chsienki) | [jcouv](https://github.com/jcouv) |
| [Native ints](https://github.com/dotnet/csharplang/issues/435) | [features/NativeInt](https://github.com/dotnet/roslyn/tree/features/NativeInt) | [Merged into 16.7p1](https://github.com/dotnet/roslyn/issues/38821) | [cston](https://github.com/cston) | [333fred](https://github.com/333fred), [gafter](https://github.com/gafter) | [jaredpar](https://github.com/jaredpar) |
| [Attributes on local functions](https://github.com/dotnet/csharplang/issues/1888) | [features/local-function-attributes](https://github.com/dotnet/roslyn/tree/features/local-function-attributes) | [Merged](https://github.com/dotnet/roslyn/issues/38801) | [RikkiGibson](https://github.com/RikkiGibson) | [agocke](https://github.com/agocke) | [agocke](https://github.com/agocke) |
| [Native ints](https://github.com/dotnet/csharplang/issues/435) | [features/NativeInt](https://github.com/dotnet/roslyn/tree/features/NativeInt) | [Merged into 16.7p1](https://github.com/dotnet/roslyn/issues/38821) | [cston](https://github.com/cston) | [333fred](https://github.com/333fred), [gafter](https://github.com/gafter) | [jaredpar](https://github.com/jaredpar) |
| [Attributes on local functions](https://github.com/dotnet/csharplang/issues/1888) | [features/local-function-attributes](https://github.com/dotnet/roslyn/tree/features/local-function-attributes) | [Merged](https://github.com/dotnet/roslyn/issues/38801) | [RikkiGibson](https://github.com/RikkiGibson) | [agocke](https://github.com/agocke) | [agocke](https://github.com/agocke) |
| [Function pointers](https://github.com/dotnet/csharplang/issues/191) | [function-pointers](https://github.com/dotnet/roslyn/tree/features/function-pointers) | [In Progress](https://github.com/dotnet/roslyn/issues/38830) | [333fred](https://github.com/333fred) | [AlekseyTs](https://github.com/AlekseyTs) | [jaredpar](https://github.com/jaredpar) |
| [Pattern matching improvements](https://github.com/dotnet/csharplang/issues/2850) | [features/patterns3](https://github.com/dotnet/roslyn/tree/features/patterns3) | [In progress](https://github.com/dotnet/roslyn/issues/41502) ([test](https://github.com/dotnet/roslyn/issues/40727)) | [gafter](https://github.com/gafter) | [RikkiGibson](https://github.com/RikkiGibson),[agocke](https://github.com/agocke) | [gafter](https://github.com/gafter) |
| [Pattern matching improvements](https://github.com/dotnet/csharplang/issues/2850) | [features/patterns3](https://github.com/dotnet/roslyn/tree/features/patterns3) | [In progress](https://github.com/dotnet/roslyn/issues/41502) ([test](https://github.com/dotnet/roslyn/issues/40727)) | [gafter](https://github.com/gafter) | [RikkiGibson](https://github.com/RikkiGibson),[agocke](https://github.com/agocke) | [gafter](https://github.com/gafter) |
| [Static lambdas](https://github.com/dotnet/csharplang/issues/275) | [features/static-lambdas](https://github.com/dotnet/roslyn/tree/features/static-lambdas) | [In progress](https://github.com/dotnet/roslyn/issues/39606) | [CyrusNajmabadi](https://github.com/CyrusNajmabadi) | [jcouv](https://github.com/jcouv) | [jcouv](https://github.com/jcouv) |
| [Records](https://github.com/dotnet/csharplang/issues/39) | [features/records](https://github.com/dotnet/roslyn/tree/features/records) | [In progress](https://github.com/dotnet/roslyn/issues/40726) | [agocke](https://github.com/agocke) | [gafter](https://github.com/gafter), [333fred](https://github.com/333fred) | [agocke](https://github.com/agocke) |
| [Target-typed conditional](https://github.com/dotnet/csharplang/issues/2460) | [features/target-typing](https://github.com/dotnet/roslyn/tree/features/target-typing) | [In Progress](https://github.com/dotnet/roslyn/issues/43186) | [gafter](https://github.com/gafter) | TBD,TBD | [gafter](https://github.com/gafter) |
| [Covariant](https://github.com/dotnet/csharplang/issues/49) [Returns](https://github.com/dotnet/csharplang/issues/2844) | [features/covariant-returns](https://github.com/dotnet/roslyn/tree/features/covariant-returns) | [In Progress](https://github.com/dotnet/roslyn/issues/43188) | [gafter](https://github.com/gafter) | TBD,TBD | [gafter](https://github.com/gafter) |
| [Extension GetEnumerator](https://github.com/dotnet/csharplang/issues/3194) | [features/extension-foreach](https://github.com/dotnet/roslyn/tree/features/extension-foreach) | [In Progress](https://github.com/dotnet/roslyn/issues/43184) | [YairHalberstadt](https://github.com/YairHalberstadt) | [333fred](https://github.com/333fred),TBD | [333fred](https://github.com/333fred) |
| [Records](https://github.com/dotnet/csharplang/issues/39) | [features/records](https://github.com/dotnet/roslyn/tree/features/records) | [In progress](https://github.com/dotnet/roslyn/issues/40726) | [agocke](https://github.com/agocke) | [gafter](https://github.com/gafter), [333fred](https://github.com/333fred) | [agocke](https://github.com/agocke) |
| [Target-typed conditional](https://github.com/dotnet/csharplang/issues/2460) | [features/target-typing](https://github.com/dotnet/roslyn/tree/features/target-typing) | [In Progress](https://github.com/dotnet/roslyn/issues/43186) | [gafter](https://github.com/gafter) | [agocke](https://github.com/agocke), [RikkiGibson](https://github.com/RikkiGibson) | [gafter](https://github.com/gafter) |
| [Covariant](https://github.com/dotnet/csharplang/issues/49) [Returns](https://github.com/dotnet/csharplang/issues/2844) | [features/covariant-returns](https://github.com/dotnet/roslyn/tree/features/covariant-returns) | [In Progress](https://github.com/dotnet/roslyn/issues/43188) | [gafter](https://github.com/gafter) | TBD,TBD | [gafter](https://github.com/gafter) |
| [Extension GetEnumerator](https://github.com/dotnet/csharplang/issues/3194) | [features/extension-foreach](https://github.com/dotnet/roslyn/tree/features/extension-foreach) | [In Progress](https://github.com/dotnet/roslyn/issues/43184) | [YairHalberstadt](https://github.com/YairHalberstadt) | [333fred](https://github.com/333fred) | [333fred](https://github.com/333fred) |
| [Module initializers](https://github.com/RikkiGibson/csharplang/blob/module-initializers/proposals/module-initializers.md) | TBD | [In progress / design](https://github.com/dotnet/roslyn/issues/40500) | [RikkiGibson](https://github.com/RikkiGibson) [jnm2](https://github.com/jnm2)| [AlekseyTs](https://github.com/AlekseyTs) | [gafter](https://github.com/gafter) |
# C# 8.0
......
Source Generators
=================
Summary
-------
Source generators provide a mechanism through which source code can be generated at compile time
and added to the compilation. The additional source can be based on the content of the compilation,
enabling some meta-programming scenarios.
Deprecation notice
----------
Like all pre-release features, code generators will need to be specially enabled, either by passing
`/features:replace` directly to `csc` or by setting the `<Features>replace</Features>` flag in the project file.
Scenarios
---------
* Generate `BoundNode` classes from record definitions.
* Implement `System.ComponentModel.INotifyPropertyChanged`.
* Support code contracts defined through attributes.
* Generate types from structured data similar to F# Type Providers.
* Serialization/deserialization (see https://github.com/agocke/json-serializer)
General
-------
Source generators are implementations of `Microsoft.CodeAnalysis.SourceGenerator`.
```csharp
public abstract class SourceGenerator
{
public abstract void Execute(SourceGeneratorContext context);
}
```
`SourceGenerator` implementations are defined in external assemblies passed to the compiler
using the same `-analyzer:` option used for diagnostic analyzers. Valid source generators
must:
1. Implement `Microsoft.CodeAnalysis.SourceGenerator`
1. Be decorated with the `Microsoft.CodeAnalysis.SourceGeneratorAttribute` to indicate
supported languages.
An assembly can contain a mix of diagnostic analyzers and source generators.
Since generators are loaded from external assemblies, a generator cannot be used to build
the assembly in which it is defined.
`SourceGenerator` has a single `Execute` method that is called by the host -- either the IDE
or the command-line compiler. `Execute` provides
access to the `Compilation` and allows adding source and reporting diagnostics.
```csharp
public abstract class SourceGeneratorContext
{
public abstract Compilation Compilation { get; }
public abstract void ReportDiagnostic(Diagnostic diagnostic);
public abstract void AddCompilationUnit(string name, SyntaxTree tree);
}
```
Generators add source to the compilation using `context.AddCompilationUnit()`.
Source can be added to the compilation but not replaced or rewritten. The `replace` keyword allows redefining methods.
The command-line compiler persists the generated source to support scenarios that require
files on disk (e.g.: navigating to error locations; debugging and setting breakpoints in generated code).
Generated source is persisted to a `GeneratedFiles/{GeneratorAssemblyName}` subfolder within the
`CommandLineArguments.OutputDirectory` using the `name` argument to `AddCompilationUnit`, and an extension based on the language.
For instance, on Windows a call to ```AddCompilationUnit("MyCode", ...);```
from `MyGenerator.dll` for a C# project would be persisted as `obj/debug/GeneratedFiles/MyGenerator.dll/MyCode.cs`.
The `name` must be a valid file name, must be unique across all files produced by the generator for the compilation,
and should be deterministic. (The content of the generated source should be deterministic as well. Both requirements
are necessary to ensure builds are deterministic.) By convention, `name` should be the namespace-qualified
type name of the type modified or generated.
`build clean` should be modified to delete the `GeneratedFiles/` directory.
Execution
---------
Source generators are executed by the command-line compilers and the IDE. The generators
are obtained from the `AnalyzerReference.GetSourceGenerators` for each analyzer reference
specified on the command-line or in the project. `GetSourceGenerators` uses reflection to find types that
inherit from `SourceGenerator` and instantiates those types.
```csharp
public abstract class AnalyzerReference
{
...
public abstract ImmutableArray<SourceGenerator> GetSourceGenerators(string language);
}
```
A public `GeneratedSource` extension method on `Compilation` executes each generator in a collection of generators
and returns the collection of `SyntaxTrees` and `Diagnostics`.
(`GenerateSource` is called by the command-line compilers and IDE.)
If `writeToDisk` is true, the generated source is persisted to `outputPath`. Regardless of whether the tree is persisted
to disk, `SyntaxTree.FilePath` is set.
```csharp
public static class SourceGeneratorExtensions
{
public static ImmutableArray<SyntaxTree> GenerateSource(
this Compilation compilation,
ImmutableArray<SourceGenerator> generators,
string outputPath,
bool writeToDisk,
out ImmutableArray<Diagnostic> diagnostics,
CancellationToken cancellationToken);
}
```
The compilers and IDE add `SyntaxTrees` returned by `GenerateSource` to the `Compilation` to
generate a new `Compilation` that is compiled and passed to any diagnostic analyzers.
Diagnostics from `GenerateSource` are reported to the user.
In the command-line compilers, the compile will be aborted if the diagnostics include errors.
In the IDE, diagnostics are included in the Errors list and errors do not prevent subsequent binding or analysis.
Exceptions thrown from generators are caught by the `GenerateSource` and reported as errors.
Generators may be executed in parallel by `GenerateSource` using the same policy that is used for
concurrent execution of `DiagnosticAnalyzers`.
Modifying Types
---------------
To add members to an existing class, the generated source will define a `partial class`.
In C# this means the original class definition must be defined as `partial`.
To redefine members in generated source, there are new language keywords: `replace` and `original`.
`replace` is a declaration modifier applied to the redefined method, property, or event.
`original` is a reference to the member that is replaced in a `replace` member.
`replace` and `original` are contextual keywords: `replace` is a keyword only when used as a member modifier;
`original` is a keyword only when used within a `replace` method (similar to parser handling of `async` and `await`).
```csharp
// original.cs:
partial class C
{
void F() { }
int P { get; set; }
object this[int index] { get { return null; } }
event EventHandler E;
}
// replace.cs:
partial class C
{
replace void F() { original(); }
replace int P
{
get { return original; }
set { original += value; } // P.get and P.set
}
replace object this[int index]
{
get { return original[index]; }
}
replace event EventHandler E
{
add { original += value; }
remove { original -= value; }
}
}
```
The following `class` and `struct` members can be replaced:
1. Static and instance methods, properties, and events
1. Explicit interface implementations of members
1. User defined operators
1. Static constructors
1. Instance constructors
1. Instance destructors
1. Extension methods
The default constructor can be added by a generator but not replaced.
The following must match when replacing a member:
1. Signature: name, accessibility, arity, return type, parameter number, parameter types and ref-ness
1. Parameter names and default values (to prevent changing the interpretation of call-sites)
1. Type parameters and constraints
1. Attributes on the member, parameters, and return type (including `this` for extension methods)
1. Set of accessors in properties and events
1. Explicit implementation of the member
1. Modifiers: `sealed`, `static`, `virtual`, `new`, and `override`.
If type parameter constraints are specified in the original method but absent in the `replace` method,
the original constraints are used (similar to constraints in overrides).
`abstract` and `extern` members cannot be replaced.
`partial` methods can be replaced although the `partial` modifier is not allowed on the `replace` method.
`async` need not match.
If there are multiple `replace` definitions for the same member, the compiler will report an error
that there are multiple definitions for the member.
_To support scenarios where multiple generators may replace the same method, it will
be necessary to determine an order for the chain of replacements. One possibility is
to use the order of the assemblies containing the generators in the `Compilation`. Another possibility is
to require the ambiguous `replace` members to have explicit ```[Order(...)]``` attributes that indicate the
relative order._
Code Generation
---------------
The replacing methods will have the signature in metadata of the original method,
including the `virtual` and `final` metadata attributes and `override` clause.
The original methods will be emitted with mangled names to avoid multiple definitions with the same
name and signature when the containing type is loaded from metadata.
The mangled name is `<M>v__I` where M is the original method name, qualified by namespace and
type name if an explicit interface implementation, and where I is an index since there may be multiple
overloads that are replaced. (Since the compiler disallows methods and property or event accessors
with the same signatures, the same name mangling can be used for methods and accessors.)
To ensure the mangled names are deterministic, the index is from the original overloads sorted by syntax location.
Since the original methods will have mangled names, the methods are not callable
from source and are therefore emitted as `private`.
In the EE and REPL, which evaluate expressions in the context of methods loaded from metadata (even for projects from source),
the `Binder` implementations for those scenarios will bind `original` to the method with the mangled name.
Since there may be several methods named `<M>v__I` for a given M, with distinct signatures,
the Binder compares method signatures to find the actual original method.
The original methods in metadata will not override any base class or interface members so original
methods will be emitted without `virtual` and with no `override` clause.
If the replacing method does not call the original method (in scenarios where methods are rewritten
completely), the original method will be unused. And since it has a mangled name, the method is not
callable. To avoid bloating the assembly, the compiler should drop those unused
uncallable methods in optimized builds.
Original property and events will be dropped from metadata although the original accessors will be emitted.
The EE and REPL will need to recognize that certain mangled names map to accessors rather than oridinary methods.
CodeAnalysis API
----------------
`SyntaxKind` includes `ReplaceKeyword` and `OriginalKeyword`.
`DeclarationModifiers` includes a `Replace` member.
`IMethodSymbol`, `IPopertySymbol`, `IEventSymbol` include `Replaced` and `ReplacedBy` properties.
Member lookup in expressions in the `SemanticModel` returns the replacing definition.
The semantic model for `original` will return the replaced symbol.
IDE
---
The IDE deals with `Workspace`, `Solution`, `Project`, and `Document`.
Generated source is exposed as `Documents` added to the `Project`.
The generated source is updated in the `Project` on load and on explicit build. At other times, the generated source is potentially stale.
The generated source are files on disk although the IDE does not persist the generated source, only the command-line compiler does.
On load and on build, the IDE will invoke `GenerateSource()` with a `Compilation` from the original source and use
the `FilePath` from each generated `SyntaxTree` to update the `Solution` in the `Workspace` to point to the new set of source files.
`Document.IsGenerated` indicates whether the source was generated. Generated source will be readonly in the IDE
and certain tools such as Rename treat generated source specially.
This proposal has been deprecated in favor of the newer [Source Generators](source-generators.md) proposal.
## Checklist of work for Source Generators:
- [ ] GenerateSource
- [ ] Return errors to caller
- [ ] Catch exceptions and return to caller as errors
- [ ] Execute generators in parallel using same concurrent policy as analyzers (P2)
- [ ] `AddCompilationUnit`
- [ ] Create `GeneratedSource` directory (on demand) in `$OutputPath`
- [ ] Create separate directories for each generator (on demand), using generator assembly file name. e.g.: `$OutputPath/GeneratedSource/MyGenerator.dll/MySource.cs`
- [ ] `AddCompilation` should take `SourceText` and `ParseOptions` rather than `SyntaxTree`: ```AddCompilation(string name, SourceText text, ParseOptions options)```
- [ ] Add `IsGenerated` property to `SyntaxTree`. See `DocumentInfo.IsGenerated` and ```AnalyzerDriver.IsGeneratedCode(SyntaxTree tree)```.
- [ ] Incremental parsing when adding/removing `replace`. See `src/Compilers/CSharp/Test/Syntax/IncrementalParsing/ReplaceOriginalTests.cs`
- [ ] Match signature on replace/original
- [ ] Compare parameter names
- [ ] Compare default values
- [ ] Compare type parameter names and constraints
- [ ] Inherit type parameter constraints from original definition if absent in `replace`
- [ ] Compare set of property/event accessors
- [ ] Compare modifiers: `sealed`, `static`, `virtual`, `new`, and `override`
- [ ] `replace` members
- [ ] `replace` for explicit implementation
- [ ] `replace` for user-defined operators
- [ ] `replace` for static and instance constructors
- [ ] Allow calling `base` constructor in original constructor
- [ ] Allow writing to `readonly` fields in original constructor
- [ ] `replace` for destructors
- [ ] `replace` for field-like events
- [ ] `replace` for extension methods
- [ ] `replace` partial methods
- [ ] `replace` external method
- [ ] Add `Replaced` and `ReplacedBy` to `ISymbol`
- [ ] Report diagnostics
- [ ] Report error for multiple `replace`
- [ ] Report error for signature mismatch
- [ ] Report error for `replace` with no original
- [ ] Report error for a `replace` member with `extern` or `abstract`
- [ ] Allow a member to be replaced multiple times (P2)
- [ ] Use ```[Order]``` attributes to determine chain
- [ ] Emit metadata
- [ ] Include namespace and type name in mangled name of original explicit interface implementation
- [ ] Include (deterministic) unique id in mangled name of original overloaded methods: ```<M>v__0```, ```<M>v__1```, ...
- [ ] Drop original methods that are not called in optimized builds (P2)
- [ ] IDE
- [ ] Include diagnostics from `SourceGenerator.Execute` in Errors list (P2)
- [ ] EnC
- [ ] Changes that add/remove `replace` are considered rude edits
- [ ] EE
- [ ] Bind `original` to mangled method or accessor
- [ ] VB
- [ ] `Replace` keyword in parser and syntax
- [ ] Implement `Replaced` and `ReplacedBy` on `Symbol`
......@@ -30,7 +30,7 @@
<RoslynDiagnosticsNugetPackageVersion>3.0.0-beta2.20169.3</RoslynDiagnosticsNugetPackageVersion>
<CodeStyleLayerCodeAnalysisVersion>3.3.1</CodeStyleLayerCodeAnalysisVersion>
<MicrosoftCodeAnalysisTestingVersion>1.0.1-beta1.20210.2</MicrosoftCodeAnalysisTestingVersion>
<CodeStyleAnalyzerVersion>3.6.0-2.20157.5</CodeStyleAnalyzerVersion>
<CodeStyleAnalyzerVersion>3.7.0-1.20210.7</CodeStyleAnalyzerVersion>
<VisualStudioEditorPackagesVersion>16.4.248</VisualStudioEditorPackagesVersion>
<ILToolsPackageVersion>5.0.0-alpha1.19409.1</ILToolsPackageVersion>
<MicrosoftVisualStudioLanguageServerPackagesVersion>16.3.27-develop-gdd55e997</MicrosoftVisualStudioLanguageServerPackagesVersion>
......@@ -51,7 +51,7 @@
<ICSharpCodeDecompilerVersion>5.0.2.5153</ICSharpCodeDecompilerVersion>
<MicrosoftBuildVersion>15.3.409</MicrosoftBuildVersion>
<MicrosoftBuildFrameworkVersion>15.3.409</MicrosoftBuildFrameworkVersion>
<MicrosoftBuildLocatorVersion>1.2.2</MicrosoftBuildLocatorVersion>
<MicrosoftBuildLocatorVersion>1.2.6</MicrosoftBuildLocatorVersion>
<MicrosoftBuildRuntimeVersion>15.3.409</MicrosoftBuildRuntimeVersion>
<MicrosoftBuildTasksCoreVersion>15.3.409</MicrosoftBuildTasksCoreVersion>
<!--
......@@ -214,7 +214,7 @@
<xunitVersion>2.4.1-pre.build.4059</xunitVersion>
<xunitanalyzersVersion>0.10.0</xunitanalyzersVersion>
<xunitassertVersion>$(xunitVersion)</xunitassertVersion>
<XunitCombinatorialVersion>1.2.7</XunitCombinatorialVersion>
<XunitCombinatorialVersion>1.3.2</XunitCombinatorialVersion>
<xunitextensibilitycoreVersion>$(xunitVersion)</xunitextensibilitycoreVersion>
<xunitrunnerconsoleVersion>2.4.1-pre.build.4059</xunitrunnerconsoleVersion>
<xunitrunnerwpfVersion>1.0.51</xunitrunnerwpfVersion>
......@@ -245,75 +245,7 @@
<MicrosoftVisualStudioStaticReviewsEmbeddableVersion>0.1.102-alpha</MicrosoftVisualStudioStaticReviewsEmbeddableVersion>
<MicrosoftBclAsyncInterfacesVersion>1.1.0</MicrosoftBclAsyncInterfacesVersion>
</PropertyGroup>
<!--
The following packages are considered implementation details and will not be included
in the list of dependencies of Roslyn packages. They won't flow as package references
to the projects that reference Roslyn packages.
-->
<ItemGroup>
<PrivateVisualStudioPackage Include="EnvDTE" />
<PrivateVisualStudioPackage Include="EnvDTE80" />
<PrivateVisualStudioPackage Include="Microsoft.Internal.Performance.CodeMarkers.DesignTime" />
<PrivateVisualStudioPackage Include="Microsoft.Internal.VisualStudio.Shell.Interop.14.0.DesignTime" />
<PrivateVisualStudioPackage Include="Microsoft.MSXML" />
<PrivateVisualStudioPackage Include="Microsoft.ServiceHub.Client" />
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.CallHierarchy.Package.Definitions" />
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.ComponentModelHost" />
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.CodingConventions" />
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.CoreUtility" />
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.Debugger.Engine-implementation" />
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.Debugger.Metadata-implementation" />
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.Debugger.UI.Interfaces" />
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.Designer.Interfaces" />
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.Editor" />
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.GraphModel" />
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.ImageCatalog" />
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.Imaging" />
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.Language.CallHierarchy" />
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.Language.Intellisense" />
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.Language.NavigateTo.Interfaces" />
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.Language.StandardClassification" />
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.LanguageServer.Client" />
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.LiveShare.LanguageServices.Guest" />
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.LiveShare.WebEditors" />
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.OLE.Interop" />
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.Progression.CodeSchema" />
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.Progression.Common" />
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.Progression.Interfaces" />
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.RemoteControl" />
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.SDK.EmbedInteropTypes" />
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.Shell.15.0" />
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.Shell.Design" />
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.Shell.Framework" />
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.Shell.Immutable.10.0" />
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.Shell.Interop.9.0" />
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.Shell.Interop.10.0" />
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.Shell.Interop.11.0" />
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.Shell.Interop.12.1.DesignTime" />
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.Shell.Interop.14.0.DesignTime" />
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.Shell.Interop.15.0.DesignTime" />
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.Shell.Interop.15.3.DesignTime" />
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.Shell.Interop.15.7.DesignTime" />
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.Telemetry" />
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.Text.Data" />
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.Text.Logic" />
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.Text.UI" />
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.Text.UI.Wpf" />
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.TextManager.Interop.10.0" />
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.TextManager.Interop.12.0" />
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.TextManager.Interop.12.1.DesignTime" />
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.TextManager.Interop.16.0.DesignTime" />
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.Utilities" />
<PrivateVisualStudioPackage Include="Microsoft.VSSDK.BuildTools" />
<PrivateVisualStudioPackage Include="Newtonsoft.Json" />
<PrivateVisualStudioPackage Include="NuGet.VisualStudio" />
<PrivateVisualStudioPackage Include="StreamJsonRpc" />
<PrivateVisualStudioPackage Include="VSLangProj" />
<PrivateVisualStudioPackage Include="VSLangProj2" />
<PrivateVisualStudioPackage Include="VSLangProj80" />
<PrivateVisualStudioPackage Include="VSLangProj140" />
<PrivateVisualStudioPackage Include="VsWebsite.Interop" />
</ItemGroup>
<PropertyGroup>
<UsingToolPdbConverter>true</UsingToolPdbConverter>
<UsingToolSymbolUploader>true</UsingToolSymbolUploader>
......
......@@ -351,6 +351,12 @@ function TestUsingOptimizedRunner() {
# Minimize all windows to avoid interference during integration test runs
$shell = New-Object -ComObject "Shell.Application"
$shell.MinimizeAll()
# Set registry to take dump automatically when test process crashes
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" /f
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" /f /v DumpType /t REG_DWORD /d 2
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" /f /v DumpCount /t REG_DWORD /d 2
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" /f /v DumpFolder /t REG_SZ /d "$LogDir"
}
}
......
......@@ -201,13 +201,6 @@
</PropertyGroup>
</Target>
<!--
Exclude private Visual Studio packages from dependencies of Roslyn packages.
-->
<ItemGroup Condition="'$(IsPackable)' == 'true'">
<PackageReference Update="@(PrivateVisualStudioPackage)" PrivateAssets="all"/>
</ItemGroup>
<!-- Make sure additional files show up in Solution Explorer -->
<ItemGroup>
<!--
......
......@@ -173,7 +173,7 @@ public bool TryAddHashedSymbol(IOperation value, bool seenHash)
return false;
}
private static bool TryGetFieldOrProperty(IOperation operation, [NotNullWhen(true)]out ISymbol? symbol)
private static bool TryGetFieldOrProperty(IOperation operation, [NotNullWhen(true)] out ISymbol? symbol)
{
operation = Unwrap(operation);
......
......@@ -521,8 +521,8 @@ public void CloseMethod(BoundStatement body)
SynthesizedLocalKind kind = SynthesizedLocalKind.LoweringTemp
#if DEBUG
,
[CallerLineNumber]int createdAtLineNumber = 0,
[CallerFilePath]string? createdAtFilePath = null
[CallerLineNumber] int createdAtLineNumber = 0,
[CallerFilePath] string? createdAtFilePath = null
#endif
)
{
......@@ -1368,8 +1368,8 @@ internal BoundExpression Not(BoundExpression expression)
SynthesizedLocalKind kind = SynthesizedLocalKind.LoweringTemp,
SyntaxNode? syntaxOpt = null
#if DEBUG
, [CallerLineNumber]int callerLineNumber = 0
, [CallerFilePath]string? callerFilePath = null
, [CallerLineNumber] int callerLineNumber = 0
, [CallerFilePath] string? callerFilePath = null
#endif
)
{
......
......@@ -38,8 +38,8 @@ internal sealed class SynthesizedLocal : LocalSymbol
RefKind refKind = RefKind.None
#if DEBUG
,
[CallerLineNumber]int createdAtLineNumber = 0,
[CallerFilePath]string createdAtFilePath = null
[CallerLineNumber] int createdAtLineNumber = 0,
[CallerFilePath] string createdAtFilePath = null
#endif
)
{
......
......@@ -28,8 +28,8 @@ public class CodeGen_DynamicTests : CSharpTestBase
string expectedUnoptimizedIL = null,
MetadataReference[] references = null,
bool allowUnsafe = false,
[CallerFilePath]string callerPath = null,
[CallerLineNumber]int callerLine = 0,
[CallerFilePath] string callerPath = null,
[CallerLineNumber] int callerLine = 0,
CSharpParseOptions parseOptions = null,
Verification verify = Verification.Passes)
{
......
......@@ -74,7 +74,7 @@ internal static class NativeMethods
internal static extern bool CreateProcess
(
string? lpApplicationName,
[In, Out]StringBuilder lpCommandLine,
[In, Out] StringBuilder lpCommandLine,
IntPtr lpProcessAttributes,
IntPtr lpThreadAttributes,
[In, MarshalAs(UnmanagedType.Bool)]
......
......@@ -391,7 +391,7 @@ protected internal override void AddResponseFileCommands(CommandLineBuilderExten
/// Then we look at the resulting list of strings, and remove any that are
/// illegal identifiers, and pass the remaining ones through to the compiler.
///
/// Note that CSharp does support assigning a value to the constants ... in
/// Note that CSharp doesn't support assigning a value to the constants ... in
/// other words, a constant is either defined or not defined ... it can't have
/// an actual value.
/// </summary>
......
......@@ -15,25 +15,25 @@ public virtual int GetTokenFromSig(byte* voidPointerSig, int byteCountSig)
public virtual int GetSigFromToken(
int standaloneSignature,
[Out]byte** signature,
[Out]int* signatureLength)
[Out] byte** signature,
[Out] int* signatureLength)
=> throw new NotImplementedException();
public virtual int GetTypeDefProps(
int typeDef,
[Out]char* qualifiedName,
[Out] char* qualifiedName,
int qualifiedNameBufferLength,
[Out]int* qualifiedNameLength,
[Out]TypeAttributes* attributes,
[Out]int* baseType)
[Out] int* qualifiedNameLength,
[Out] TypeAttributes* attributes,
[Out] int* baseType)
=> throw new NotImplementedException();
public virtual int GetTypeRefProps(
int typeRef,
[Out]int* resolutionScope, // ModuleRef or AssemblyRef
[Out]char* qualifiedName,
[Out] int* resolutionScope, // ModuleRef or AssemblyRef
[Out] char* qualifiedName,
int qualifiedNameBufferLength,
[Out]int* qualifiedNameLength)
[Out] int* qualifiedNameLength)
=> throw new NotImplementedException();
public virtual int GetNestedClassProps(int nestedClass, out int enclosingClass)
......
......@@ -32,11 +32,11 @@ public override int GetTokenFromSig(byte* voidPointerSig, int byteCountSig)
public override int GetTypeDefProps(
int typeDef,
[Out]char* qualifiedName,
[Out] char* qualifiedName,
int qualifiedNameBufferLength,
[Out]int* qualifiedNameLength,
[Out]TypeAttributes* attributes,
[Out]int* baseType)
[Out] int* qualifiedNameLength,
[Out] TypeAttributes* attributes,
[Out] int* baseType)
{
Debug.Assert(baseType == null);
......@@ -65,10 +65,10 @@ public override int GetTokenFromSig(byte* voidPointerSig, int byteCountSig)
public override int GetTypeRefProps(
int typeRef,
[Out]int* resolutionScope, // ModuleRef or AssemblyRef
[Out]char* qualifiedName,
[Out] int* resolutionScope, // ModuleRef or AssemblyRef
[Out] char* qualifiedName,
int qualifiedNameBufferLength,
[Out]int* qualifiedNameLength)
[Out] int* qualifiedNameLength)
=> throw new NotImplementedException();
public override int GetNestedClassProps(int nestedClass, out int enclosingClass)
......
......@@ -33,19 +33,19 @@ internal static string DiaSymReaderModuleName
[DefaultDllImportSearchPaths(DllImportSearchPath.AssemblyDirectory | DllImportSearchPath.SafeDirectories)]
[DllImport(DiaSymReaderModuleName32, EntryPoint = CreateSymReaderFactoryName)]
private extern static void CreateSymReader32(ref Guid id, [MarshalAs(UnmanagedType.IUnknown)]out object symReader);
private extern static void CreateSymReader32(ref Guid id, [MarshalAs(UnmanagedType.IUnknown)] out object symReader);
[DefaultDllImportSearchPaths(DllImportSearchPath.AssemblyDirectory | DllImportSearchPath.SafeDirectories)]
[DllImport(DiaSymReaderModuleName64, EntryPoint = CreateSymReaderFactoryName)]
private extern static void CreateSymReader64(ref Guid id, [MarshalAs(UnmanagedType.IUnknown)]out object symReader);
private extern static void CreateSymReader64(ref Guid id, [MarshalAs(UnmanagedType.IUnknown)] out object symReader);
[DefaultDllImportSearchPaths(DllImportSearchPath.AssemblyDirectory | DllImportSearchPath.SafeDirectories)]
[DllImport(DiaSymReaderModuleName32, EntryPoint = CreateSymWriterFactoryName)]
private extern static void CreateSymWriter32(ref Guid id, [MarshalAs(UnmanagedType.IUnknown)]out object symWriter);
private extern static void CreateSymWriter32(ref Guid id, [MarshalAs(UnmanagedType.IUnknown)] out object symWriter);
[DefaultDllImportSearchPaths(DllImportSearchPath.AssemblyDirectory | DllImportSearchPath.SafeDirectories)]
[DllImport(DiaSymReaderModuleName64, EntryPoint = CreateSymWriterFactoryName)]
private extern static void CreateSymWriter64(ref Guid id, [MarshalAs(UnmanagedType.IUnknown)]out object symWriter);
private extern static void CreateSymWriter64(ref Guid id, [MarshalAs(UnmanagedType.IUnknown)] out object symWriter);
[DllImport("kernel32")]
private static extern IntPtr LoadLibrary(string path);
......@@ -56,7 +56,7 @@ internal static string DiaSymReaderModuleName
[DllImport("kernel32")]
private static extern IntPtr GetProcAddress(IntPtr hModule, string procedureName);
private delegate void NativeFactory(ref Guid id, [MarshalAs(UnmanagedType.IUnknown)]out object instance);
private delegate void NativeFactory(ref Guid id, [MarshalAs(UnmanagedType.IUnknown)] out object instance);
#if !NET20
private static Lazy<Func<string, string>> s_lazyGetEnvironmentVariable = new Lazy<Func<string, string>>(() =>
......
......@@ -125,12 +125,12 @@ internal interface ISymUnmanagedWriter8 : ISymUnmanagedWriter5
void InitializeDeterministic([MarshalAs(UnmanagedType.IUnknown)] object emitter, [MarshalAs(UnmanagedType.IUnknown)] object stream);
// ISymUnmanagedWriter7
unsafe void UpdateSignatureByHashingContent([In]byte* buffer, int size);
unsafe void UpdateSignatureByHashingContent([In] byte* buffer, int size);
// ISymUnmanagedWriter8
void UpdateSignature(Guid pdbId, uint stamp, int age);
unsafe void SetSourceServerData([In]byte* data, int size);
unsafe void SetSourceLinkData([In]byte* data, int size);
unsafe void SetSourceServerData([In] byte* data, int size);
unsafe void SetSourceLinkData([In] byte* data, int size);
}
/// <summary>
......
......@@ -40,7 +40,7 @@ private WrappedValue ComputeValue(TKey key)
return new WrappedValue { Value = value };
}
internal bool TryGetValue(TKey key, [MaybeNull] [NotNullWhen(true)] out TValue value)
internal bool TryGetValue(TKey key, [MaybeNull][NotNullWhen(true)] out TValue value)
{
// Catch any exceptions from the computeValue callback, which calls into user code.
try
......
......@@ -23,7 +23,7 @@ public CompilationAnalysisValueProvider(AnalysisValueProvider<TKey, TValue> anal
_valueMap = new Dictionary<TKey, TValue>(analysisValueProvider.KeyComparer);
}
internal bool TryGetValue(TKey key, [MaybeNull] [NotNullWhen(true)] out TValue value)
internal bool TryGetValue(TKey key, [MaybeNull][NotNullWhen(true)] out TValue value)
{
// First try to get the cached value for this compilation.
lock (_valueMap)
......
......@@ -223,12 +223,12 @@ public virtual void ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags an
/// <param name="valueProvider">Provider that computes the underlying value.</param>
/// <param name="value">Value associated with the key.</param>
/// <returns>Returns true on success, false otherwise.</returns>
public bool TryGetValue<TValue>(SourceText text, SourceTextValueProvider<TValue> valueProvider, [MaybeNull] [NotNullWhen(true)] out TValue value)
public bool TryGetValue<TValue>(SourceText text, SourceTextValueProvider<TValue> valueProvider, [MaybeNull][NotNullWhen(true)] out TValue value)
{
return TryGetValue(text, valueProvider.CoreValueProvider, out value);
}
private bool TryGetValue<TKey, TValue>(TKey key, AnalysisValueProvider<TKey, TValue> valueProvider, [MaybeNull] [NotNullWhen(true)] out TValue value)
private bool TryGetValue<TKey, TValue>(TKey key, AnalysisValueProvider<TKey, TValue> valueProvider, [MaybeNull][NotNullWhen(true)] out TValue value)
where TKey : class
{
DiagnosticAnalysisContextHelpers.VerifyArguments(key, valueProvider);
......@@ -462,7 +462,7 @@ public virtual void RegisterOperationAction(Action<OperationAnalysisContext> act
/// <param name="valueProvider">Provider that computes the underlying value.</param>
/// <param name="value">Value associated with the key.</param>
/// <returns>Returns true on success, false otherwise.</returns>
public bool TryGetValue<TValue>(SourceText text, SourceTextValueProvider<TValue> valueProvider, [MaybeNull] [NotNullWhen(true)] out TValue value)
public bool TryGetValue<TValue>(SourceText text, SourceTextValueProvider<TValue> valueProvider, [MaybeNull][NotNullWhen(true)] out TValue value)
{
return TryGetValue(text, valueProvider.CoreValueProvider, out value);
}
......@@ -477,19 +477,19 @@ public bool TryGetValue<TValue>(SourceText text, SourceTextValueProvider<TValue>
/// <param name="valueProvider">Provider that computes the underlying value.</param>
/// <param name="value">Value associated with the key.</param>
/// <returns>Returns true on success, false otherwise.</returns>
public bool TryGetValue<TValue>(SyntaxTree tree, SyntaxTreeValueProvider<TValue> valueProvider, [MaybeNull] [NotNullWhen(true)] out TValue value)
public bool TryGetValue<TValue>(SyntaxTree tree, SyntaxTreeValueProvider<TValue> valueProvider, [MaybeNull][NotNullWhen(true)] out TValue value)
{
return TryGetValue(tree, valueProvider.CoreValueProvider, out value);
}
private bool TryGetValue<TKey, TValue>(TKey key, AnalysisValueProvider<TKey, TValue> valueProvider, [MaybeNull] [NotNullWhen(true)] out TValue value)
private bool TryGetValue<TKey, TValue>(TKey key, AnalysisValueProvider<TKey, TValue> valueProvider, [MaybeNull][NotNullWhen(true)] out TValue value)
where TKey : class
{
DiagnosticAnalysisContextHelpers.VerifyArguments(key, valueProvider);
return TryGetValueCore(key, valueProvider, out value);
}
internal virtual bool TryGetValueCore<TKey, TValue>(TKey key, AnalysisValueProvider<TKey, TValue> valueProvider, [MaybeNull] [NotNullWhen(true)] out TValue value)
internal virtual bool TryGetValueCore<TKey, TValue>(TKey key, AnalysisValueProvider<TKey, TValue> valueProvider, [MaybeNull][NotNullWhen(true)] out TValue value)
where TKey : class
{
throw new NotImplementedException();
......@@ -568,7 +568,7 @@ public void ReportDiagnostic(Diagnostic diagnostic)
/// <param name="valueProvider">Provider that computes the underlying value.</param>
/// <param name="value">Value associated with the key.</param>
/// <returns>Returns true on success, false otherwise.</returns>
public bool TryGetValue<TValue>(SourceText text, SourceTextValueProvider<TValue> valueProvider, [MaybeNull] [NotNullWhen(true)] out TValue value)
public bool TryGetValue<TValue>(SourceText text, SourceTextValueProvider<TValue> valueProvider, [MaybeNull][NotNullWhen(true)] out TValue value)
{
return TryGetValue(text, valueProvider.CoreValueProvider, out value);
}
......@@ -583,12 +583,12 @@ public bool TryGetValue<TValue>(SourceText text, SourceTextValueProvider<TValue>
/// <param name="valueProvider">Provider that computes the underlying value.</param>
/// <param name="value">Value associated with the key.</param>
/// <returns>Returns true on success, false otherwise.</returns>
public bool TryGetValue<TValue>(SyntaxTree tree, SyntaxTreeValueProvider<TValue> valueProvider, [MaybeNull] [NotNullWhen(true)] out TValue value)
public bool TryGetValue<TValue>(SyntaxTree tree, SyntaxTreeValueProvider<TValue> valueProvider, [MaybeNull][NotNullWhen(true)] out TValue value)
{
return TryGetValue(tree, valueProvider.CoreValueProvider, out value);
}
private bool TryGetValue<TKey, TValue>(TKey key, AnalysisValueProvider<TKey, TValue> valueProvider, [MaybeNull] [NotNullWhen(true)] out TValue value)
private bool TryGetValue<TKey, TValue>(TKey key, AnalysisValueProvider<TKey, TValue> valueProvider, [MaybeNull][NotNullWhen(true)] out TValue value)
where TKey : class
{
DiagnosticAnalysisContextHelpers.VerifyArguments(key, valueProvider);
......
......@@ -202,7 +202,7 @@ public override void RegisterOperationAction(Action<OperationAnalysisContext> ac
// Issue with enforcing nullability attributes in OHI https://github.com/dotnet/roslyn/issues/42169
#pragma warning disable CS8765 // Type of parameter doesn't match overridden member because of nullability attributes.
internal override bool TryGetValueCore<TKey, TValue>(TKey key, AnalysisValueProvider<TKey, TValue> valueProvider, [MaybeNull] [NotNullWhen(true)] out TValue value)
internal override bool TryGetValueCore<TKey, TValue>(TKey key, AnalysisValueProvider<TKey, TValue> valueProvider, [MaybeNull][NotNullWhen(true)] out TValue value)
#pragma warning restore CS8765
{
var compilationAnalysisValueProvider = _compilationAnalysisValueProviderFactory.GetValueProvider(valueProvider);
......
......@@ -65,11 +65,10 @@ internal static void DumpStackTrace(Exception? exception = null, string? message
if (exception is object)
{
Console.WriteLine("Exception info");
for (Exception? current = exception; current is object; current = current!.InnerException)
for (Exception? current = exception; current is object; current = current.InnerException)
{
Console.WriteLine(current.Message);
Console.WriteLine(current.StackTrace);
current = current.InnerException;
}
}
......
......@@ -112,7 +112,7 @@ internal interface IClrStrongName
[In, MarshalAs(UnmanagedType.LPWStr)] string pwzKeyContainer,
[In] IntPtr pbKeyBlob,
[In, MarshalAs(UnmanagedType.U4)] int cbKeyBlob,
[Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 5)]byte[] ppbSignatureBlob,
[Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 5)] byte[] ppbSignatureBlob,
[MarshalAs(UnmanagedType.U4)] out int pcbSignatureBlob);
void StrongNameSignatureGenerationEx(
......
......@@ -364,7 +364,7 @@ internal partial class CommonReferenceManager<TCompilation, TAssemblySymbol>
ImmutableArray<ResolvedReference> explicitReferenceMap,
ArrayBuilder<AssemblyReferenceBinding[]> referenceBindings,
int totalReferencedAssemblyCount,
[Out]ArrayBuilder<(MetadataReference, ArraySegment<AssemblyReferenceBinding>)> result)
[Out] ArrayBuilder<(MetadataReference, ArraySegment<AssemblyReferenceBinding>)> result)
{
Debug.Assert(result.Count == 0);
......
......@@ -131,7 +131,7 @@ internal T DecodeValue<T>(SpecialType specialType)
return value;
}
internal bool TryDecodeValue<T>(SpecialType specialType, [MaybeNull] [NotNullWhen(returnValue: true)] out T value)
internal bool TryDecodeValue<T>(SpecialType specialType, [MaybeNull][NotNullWhen(returnValue: true)] out T value)
{
if (_kind == TypedConstantKind.Error)
{
......
......@@ -119,7 +119,7 @@ private static int CreateAssemblyNameObject(out IAssemblyName ppEnum, string szA
}
[DllImport("clr", EntryPoint = "CreateAssemblyNameObject", CharSet = CharSet.Unicode, PreserveSig = true)]
private static extern int RealCreateAssemblyNameObject(out IAssemblyName ppEnum, [MarshalAs(UnmanagedType.LPWStr)]string szAssemblyName, uint dwFlags, IntPtr pvReserved);
private static extern int RealCreateAssemblyNameObject(out IAssemblyName ppEnum, [MarshalAs(UnmanagedType.LPWStr)] string szAssemblyName, uint dwFlags, IntPtr pvReserved);
private const int ERROR_INSUFFICIENT_BUFFER = unchecked((int)0x8007007A);
private const int FUSION_E_INVALID_NAME = unchecked((int)0x80131047);
......
......@@ -19,7 +19,7 @@ private CSharpDecompiledSourceFormattingRule()
{
}
public override AdjustNewLinesOperation GetAdjustNewLinesOperation(
public override AdjustNewLinesOperation? GetAdjustNewLinesOperation(
SyntaxToken previousToken, SyntaxToken currentToken, AnalyzerConfigOptions options, in NextGetAdjustNewLinesOperation nextOperation)
{
var operation = GetAdjustNewLinesOperation(previousToken, currentToken);
......
......@@ -37,7 +37,7 @@ private SyntaxToken GetStringToken(string text)
}
private void Test(string stringText, string expected, RegexOptions options,
bool runSubTreeTests = true, [CallerMemberName]string name = "",
bool runSubTreeTests = true, [CallerMemberName] string name = "",
bool allowIndexOutOfRange = false,
bool allowNullReference = false,
bool allowOutOfMemory = false,
......
......@@ -970,7 +970,7 @@ public void ReferenceTest15()
<EndOfFile />
</CompilationUnit>
<Diagnostics>
<Diagnostic Message=""{WorkspacesResources.Not_enough_close_parens}"" Span=""[25..25)"" Text="""" />
<Diagnostic Message=""{FeaturesResources.Not_enough_close_parens}"" Span=""[25..25)"" Text="""" />
</Diagnostics>
<Captures>
<Capture Name=""0"" Span=""[10..25)"" Text=""((\w+(\s?)){{2,}}"" />
......@@ -1209,7 +1209,7 @@ public void ReferenceTest18()
<EndOfFile />
</CompilationUnit>
<Diagnostics>
<Diagnostic Message=""{string.Format(WorkspacesResources.Reference_to_undefined_group_name_0, "Open")}"" Span=""[20..24)"" Text=""Open"" />
<Diagnostic Message=""{string.Format(FeaturesResources.Reference_to_undefined_group_name_0, "Open")}"" Span=""[20..24)"" Text=""Open"" />
</Diagnostics>
<Captures>
<Capture Name=""0"" Span=""[10..35)"" Text=""((?'Close-Open'&gt;)[^&lt;&gt;]*)+"" />
......@@ -1847,7 +1847,7 @@ public void ReferenceTest31()
<EndOfFile />
</CompilationUnit>
<Diagnostics>
<Diagnostic Message=""{string.Format(WorkspacesResources.Reference_to_undefined_group_name_0, "Open")}"" Span=""[19..23)"" Text=""Open"" />
<Diagnostic Message=""{string.Format(FeaturesResources.Reference_to_undefined_group_name_0, "Open")}"" Span=""[19..23)"" Text=""Open"" />
</Diagnostics>
<Captures>
<Capture Name=""0"" Span=""[10..26)"" Text=""(?'Close-Open'&gt;)"" />
......
......@@ -44,7 +44,7 @@ void Main()
options: OptionOn(),
diagnosticId: AbstractRegexDiagnosticAnalyzer.DiagnosticId,
diagnosticSeverity: DiagnosticSeverity.Warning,
diagnosticMessage: string.Format(WorkspacesResources.Regex_issue_0, WorkspacesResources.Too_many_close_parens));
diagnosticMessage: string.Format(FeaturesResources.Regex_issue_0, FeaturesResources.Too_many_close_parens));
}
[Fact, Trait(Traits.Feature, Traits.Features.ValidateRegexString)]
......@@ -63,7 +63,7 @@ void Main()
options: OptionOn(),
diagnosticId: AbstractRegexDiagnosticAnalyzer.DiagnosticId,
diagnosticSeverity: DiagnosticSeverity.Warning,
diagnosticMessage: string.Format(WorkspacesResources.Regex_issue_0, WorkspacesResources.Too_many_close_parens));
diagnosticMessage: string.Format(FeaturesResources.Regex_issue_0, FeaturesResources.Too_many_close_parens));
}
[Fact, Trait(Traits.Feature, Traits.Features.ValidateRegexString)]
......
......@@ -16,7 +16,7 @@ internal class CSharpEditorInlineRenameService : AbstractEditorInlineRenameServi
[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public CSharpEditorInlineRenameService(
[ImportMany]IEnumerable<IRefactorNotifyService> refactorNotifyServices) : base(refactorNotifyServices)
[ImportMany] IEnumerable<IRefactorNotifyService> refactorNotifyServices) : base(refactorNotifyServices)
{
}
}
......
......@@ -16,7 +16,7 @@ internal class VisualBasicEditorInlineRenameService : AbstractEditorInlineRename
[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public VisualBasicEditorInlineRenameService(
[ImportMany]IEnumerable<IRefactorNotifyService> refactorNotifyServices) : base(refactorNotifyServices)
[ImportMany] IEnumerable<IRefactorNotifyService> refactorNotifyServices) : base(refactorNotifyServices)
{
}
}
......
......@@ -33,7 +33,7 @@ internal class ExecuteInInteractiveCommandHandler
[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public ExecuteInInteractiveCommandHandler(
[ImportMany]IEnumerable<Lazy<IExecuteInInteractiveCommandHandler, ContentTypeMetadata>> executeInInteractiveHandlers)
[ImportMany] IEnumerable<Lazy<IExecuteInInteractiveCommandHandler, ContentTypeMetadata>> executeInInteractiveHandlers)
{
_executeInInteractiveHandlers = executeInInteractiveHandlers;
}
......
......@@ -8,7 +8,7 @@
namespace Microsoft.CodeAnalysis.Features.EmbeddedLanguages.RegularExpressions
{
internal class RegexEmbeddedLanguageEditorFeatures : RegexEmbeddedLanguageFeatures, IEmbeddedLanguageEditorFeatures
internal class RegexEmbeddedLanguageEditorFeatures : RegexEmbeddedLanguage, IEmbeddedLanguageEditorFeatures
{
public IBraceMatcher BraceMatcher { get; }
......
......@@ -63,9 +63,9 @@ internal partial class CodeFixService : ForegroundThreadAffinitizedObject, ICode
public CodeFixService(
IThreadingContext threadingContext,
IDiagnosticAnalyzerService service,
[ImportMany]IEnumerable<Lazy<IErrorLoggerService>> loggers,
[ImportMany]IEnumerable<Lazy<CodeFixProvider, CodeChangeProviderMetadata>> fixers,
[ImportMany]IEnumerable<Lazy<IConfigurationFixProvider, CodeChangeProviderMetadata>> configurationProviders)
[ImportMany] IEnumerable<Lazy<IErrorLoggerService>> loggers,
[ImportMany] IEnumerable<Lazy<CodeFixProvider, CodeChangeProviderMetadata>> fixers,
[ImportMany] IEnumerable<Lazy<IConfigurationFixProvider, CodeChangeProviderMetadata>> configurationProviders)
: base(threadingContext, assertIsForeground: false)
{
_errorLoggers = loggers;
......
......@@ -31,7 +31,7 @@ internal class EditorLayerExtensionManager : IWorkspaceServiceFactory
[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public EditorLayerExtensionManager(
[ImportMany]IEnumerable<IExtensionErrorHandler> errorHandlers)
[ImportMany] IEnumerable<IExtensionErrorHandler> errorHandlers)
{
_errorHandlers = errorHandlers.ToList();
}
......
......@@ -10,7 +10,7 @@ namespace Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense
internal interface IController<TModel>
{
void OnModelUpdated(TModel result);
IAsyncToken BeginAsyncOperation(string name = "", object tag = null, [CallerFilePath] string filePath = "", [CallerLineNumber]int lineNumber = 0);
IAsyncToken BeginAsyncOperation(string name = "", object tag = null, [CallerFilePath] string filePath = "", [CallerLineNumber] int lineNumber = 0);
void StopModelComputation();
}
}
......@@ -130,7 +130,7 @@ public void TestPreviewServices()
var persistentService = previewWorkspace.Services.GetService<IPersistentStorageService>();
Assert.NotNull(persistentService);
var storage = persistentService.GetStorage(previewWorkspace.CurrentSolution);
using var storage = persistentService.GetStorage(previewWorkspace.CurrentSolution);
Assert.True(storage is NoOpPersistentStorage);
}
......
......@@ -21,7 +21,7 @@ class c
]]></Document>, showCompletionInArgumentLists:=showCompletionInArgumentLists)
state.SendInvokeCompletionList()
Await state.AssertSelectedCompletionItem("\A", inlineDescription:=WorkspacesResources.Regex_start_of_string_only_short)
Await state.AssertSelectedCompletionItem("\A", inlineDescription:=FeaturesResources.Regex_start_of_string_only_short)
state.SendTab()
Await state.AssertNoCompletionSession()
Assert.Contains("new Regex(""\\A"")", state.GetLineTextFromCaretPosition(), StringComparison.Ordinal)
......@@ -66,7 +66,7 @@ class c
state.SendTypeChars("[")
Await state.AssertSelectedCompletionItem($"[ {WorkspacesResources.Regex_character_group} ]")
Await state.AssertSelectedCompletionItem($"[ {FeaturesResources.Regex_character_group} ]")
state.SendDownKey()
state.SendDownKey()
state.SendDownKey()
......@@ -96,7 +96,7 @@ class c
state.SendTypeChars("\b")
Await state.AssertCompletionSession()
Await state.AssertSelectedCompletionItem("\b", description:=WorkspacesResources.Regex_backspace_character_long)
Await state.AssertSelectedCompletionItem("\b", description:=FeaturesResources.Regex_backspace_character_long)
End Using
End Function
......@@ -117,7 +117,7 @@ class c
state.SendTypeChars("\b")
Await state.AssertCompletionSession()
Await state.AssertSelectedCompletionItem("\b", description:=WorkspacesResources.Regex_word_boundary_long)
Await state.AssertSelectedCompletionItem("\b", description:=FeaturesResources.Regex_word_boundary_long)
End Using
End Function
......
......@@ -40,7 +40,7 @@ end class
state.SendTypeChars("[")
Await state.AssertSelectedCompletionItem($"[ {WorkspacesResources.Regex_character_group} ]")
Await state.AssertSelectedCompletionItem($"[ {FeaturesResources.Regex_character_group} ]")
state.SendDownKey()
state.SendDownKey()
state.SendDownKey()
......
......@@ -37,7 +37,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.EmbeddedLanguages
options:=OptionOn(),
diagnosticId:=AbstractRegexDiagnosticAnalyzer.DiagnosticId,
diagnosticSeverity:=DiagnosticSeverity.Warning,
diagnosticMessage:=String.Format(WorkspacesResources.Regex_issue_0, WorkspacesResources.Too_many_close_parens))
diagnosticMessage:=String.Format(FeaturesResources.Regex_issue_0, FeaturesResources.Too_many_close_parens))
End Function
<Fact, Trait(Traits.Feature, Traits.Features.ValidateRegexString)>
......@@ -53,7 +53,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.EmbeddedLanguages
options:=OptionOn(),
diagnosticId:=AbstractRegexDiagnosticAnalyzer.DiagnosticId,
diagnosticSeverity:=DiagnosticSeverity.Warning,
diagnosticMessage:=String.Format(WorkspacesResources.Regex_issue_0, WorkspacesResources.Too_many_close_parens))
diagnosticMessage:=String.Format(FeaturesResources.Regex_issue_0, FeaturesResources.Too_many_close_parens))
End Function
End Class
End Namespace
......@@ -101,7 +101,7 @@ internal sealed class CompilationContext
string typeNameBase,
string methodName,
DiagnosticBag diagnostics,
[NotNullWhen(true)]out CommonPEModuleBuilder? module)
[NotNullWhen(true)] out CommonPEModuleBuilder? module)
{
// Create a separate synthesized type for each evaluation method.
// (Necessary for VB in particular since the EENamedTypeSymbol.Locations
......@@ -139,8 +139,8 @@ internal sealed class CompilationContext
ImmutableArray<Alias> aliases,
CompilationTestData? testData,
DiagnosticBag diagnostics,
[NotNullWhen(true)]out CommonPEModuleBuilder? module,
[NotNullWhen(true)]out EEMethodSymbol? synthesizedMethod)
[NotNullWhen(true)] out CommonPEModuleBuilder? module,
[NotNullWhen(true)] out EEMethodSymbol? synthesizedMethod)
{
var synthesizedType = CreateSynthesizedType(syntax, typeName, methodName, aliases);
......@@ -210,8 +210,8 @@ internal sealed class CompilationContext
ImmutableArray<Alias> aliases,
CompilationTestData? testData,
DiagnosticBag diagnostics,
[NotNullWhen(true)]out CommonPEModuleBuilder? module,
[NotNullWhen(true)]out EEMethodSymbol? synthesizedMethod)
[NotNullWhen(true)] out CommonPEModuleBuilder? module,
[NotNullWhen(true)] out EEMethodSymbol? synthesizedMethod)
{
var objectType = Compilation.GetSpecialType(SpecialType.System_Object);
var synthesizedType = new EENamedTypeSymbol(
......@@ -1122,7 +1122,7 @@ private static Imports BuildImports(CSharpCompilation compilation, ImmutableArra
return true;
}
private static bool TryParseIdentifierNameSyntax(string name, [NotNullWhen(true)]out IdentifierNameSyntax? syntax)
private static bool TryParseIdentifierNameSyntax(string name, [NotNullWhen(true)] out IdentifierNameSyntax? syntax)
{
if (name == MetadataReferenceProperties.GlobalAlias)
{
......
......@@ -244,7 +244,7 @@ internal static string EscapeKeywordIdentifiers(string identifier)
/// We don't want to use the real lexer because we want to treat keywords as identifiers.
/// Since the inputs are so simple, we'll just do the lexing ourselves.
/// </remarks>
internal static bool TryParseDottedName(string input, [NotNullWhen(true)]out NameSyntax? output)
internal static bool TryParseDottedName(string input, [NotNullWhen(true)] out NameSyntax? output)
{
var pooled = PooledStringBuilder.GetInstance();
try
......
......@@ -393,8 +393,8 @@ internal static void VerifyTypeParameters(MethodSymbol method)
DkmClrCompilationResultFlags expectedFlags = DkmClrCompilationResultFlags.None,
string expectedILOpt = null,
bool expectedGeneric = false,
[CallerFilePath]string expectedValueSourcePath = null,
[CallerLineNumber]int expectedValueSourceLine = 0)
[CallerFilePath] string expectedValueSourcePath = null,
[CallerLineNumber] int expectedValueSourceLine = 0)
{
ExpressionCompilerTestHelpers.VerifyLocal<MethodSymbol>(
testData,
......
......@@ -372,8 +372,8 @@ internal static ImmutableArray<string> GetLocalNames(this ISymUnmanagedReader sy
int methodToken,
string qualifiedName,
string expectedIL,
[CallerLineNumber]int expectedValueSourceLine = 0,
[CallerFilePath]string expectedValueSourcePath = null)
[CallerLineNumber] int expectedValueSourceLine = 0,
[CallerFilePath] string expectedValueSourcePath = null)
{
var parts = qualifiedName.Split('.');
if (parts.Length != 2)
......
......@@ -556,7 +556,7 @@ static SyntaxNode GetMatchingRoot(SyntaxNode body)
int statementPart,
SyntaxNode oldBody,
SyntaxNode newBody,
[NotNullWhen(true)]out SyntaxNode? newStatement)
[NotNullWhen(true)] out SyntaxNode? newStatement)
{
SyntaxUtilities.AssertIsBody(oldBody, allowLambda: true);
SyntaxUtilities.AssertIsBody(newBody, allowLambda: true);
......
......@@ -1110,7 +1110,7 @@ private static void GetLocalNames(VariableDesignationSyntax designation, ref Lis
}
}
private static void GetLocalNames(SyntaxToken syntaxToken, [NotNull]ref List<SyntaxToken>? result)
private static void GetLocalNames(SyntaxToken syntaxToken, [NotNull] ref List<SyntaxToken>? result)
{
result ??= new List<SyntaxToken>();
result.Add(syntaxToken);
......
......@@ -20,7 +20,7 @@ internal partial class CSharpOrganizingService : AbstractOrganizingService
[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public CSharpOrganizingService(
[ImportMany]IEnumerable<Lazy<ISyntaxOrganizer, LanguageMetadata>> organizers)
[ImportMany] IEnumerable<Lazy<ISyntaxOrganizer, LanguageMetadata>> organizers)
: base(organizers.Where(o => o.Metadata.Language == LanguageNames.CSharp).Select(o => o.Value))
{
}
......
......@@ -210,7 +210,7 @@ private async Task<Document> CleanUpNewLinesAsync(Document document, TextSpan in
var shouldUseFormattingSpanCollapse = optionSet.GetOption(FormattingOptions.AllowDisjointSpanMerging);
var options = optionSet.AsAnalyzerConfigOptions(optionService, root.Language);
var textChanges = languageFormatter.Format(root, new[] { insertSpan }, shouldUseFormattingSpanCollapse, options, new[] { new CleanUpNewLinesFormatter(text) }, cancellationToken).GetTextChanges();
var textChanges = languageFormatter.Format(root, new[] { insertSpan }, shouldUseFormattingSpanCollapse, options, new[] { new CleanUpNewLinesFormatter(text) }, cancellationToken).GetTextChanges(cancellationToken);
// If there are no changes then, do less work.
if (textChanges.Count == 0)
......
......@@ -149,7 +149,6 @@ public async Task ForceAnalyzeAsync(Solution solution, ProjectId? projectId = nu
var index = 0;
foreach (var project in solution.Projects)
{
var localProject = project;
tasks[index++] = Task.Run(
() => analyzer.ForceAnalyzeProjectAsync(project, cancellationToken));
}
......
......@@ -35,7 +35,7 @@ internal partial class DiagnosticService : IDiagnosticService
[SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")]
public DiagnosticService(
IAsynchronousOperationListenerProvider listenerProvider,
[ImportMany]IEnumerable<Lazy<IEventListener, EventListenerMetadata>> eventListeners) : this()
[ImportMany] IEnumerable<Lazy<IEventListener, EventListenerMetadata>> eventListeners) : this()
{
// queue to serialize events.
_eventMap = new EventMap();
......
......@@ -174,7 +174,7 @@ private SyntaxNode FindStatement(SyntaxNode declarationBody, TextSpan span, out
int statementPart,
SyntaxNode oldBody,
SyntaxNode newBody,
[NotNullWhen(true)]out SyntaxNode? newStatement);
[NotNullWhen(true)] out SyntaxNode? newStatement);
protected abstract bool TryGetEnclosingBreakpointSpan(SyntaxNode root, int position, out TextSpan span);
......@@ -639,10 +639,10 @@ private static bool ReportFatalErrorAnalyzeDocumentAsync(ImmutableArray<ActiveSt
DocumentId documentId,
IActiveStatementTrackingService? trackingService,
ImmutableArray<ActiveStatement> oldActiveStatements,
[Out]ActiveStatement[] newActiveStatements,
[Out]ImmutableArray<LinePositionSpan>[] newExceptionRegions,
[Out]List<UpdatedMemberInfo> updatedMethods,
[Out]List<RudeEditDiagnostic> diagnostics)
[Out] ActiveStatement[] newActiveStatements,
[Out] ImmutableArray<LinePositionSpan>[] newExceptionRegions,
[Out] List<UpdatedMemberInfo> updatedMethods,
[Out] List<RudeEditDiagnostic> diagnostics)
{
Debug.Assert(oldActiveStatements.Length == newActiveStatements.Length);
Debug.Assert(oldActiveStatements.Length == newExceptionRegions.Length);
......@@ -676,9 +676,9 @@ private static bool ReportFatalErrorAnalyzeDocumentAsync(ImmutableArray<ActiveSt
DocumentId documentId,
IActiveStatementTrackingService? trackingService,
ImmutableArray<ActiveStatement> oldActiveStatements,
[In, Out]ActiveStatement[] newActiveStatements,
[In, Out]ImmutableArray<LinePositionSpan>[] newExceptionRegions,
[In, Out]ArrayBuilder<(ActiveStatementId, ActiveStatementTextSpan)> updatedTrackingSpans)
[In, Out] ActiveStatement[] newActiveStatements,
[In, Out] ImmutableArray<LinePositionSpan>[] newExceptionRegions,
[In, Out] ArrayBuilder<(ActiveStatementId, ActiveStatementTextSpan)> updatedTrackingSpans)
{
Debug.Assert(oldActiveStatements.Length == newActiveStatements.Length);
Debug.Assert(oldActiveStatements.Length == newExceptionRegions.Length);
......@@ -789,8 +789,8 @@ private static bool ReportFatalErrorAnalyzeDocumentAsync(ImmutableArray<ActiveSt
SyntaxNode newRoot,
DocumentId documentId,
IActiveStatementTrackingService? trackingService,
[In, Out]ActiveStatement[] newActiveStatements,
[In, Out]ImmutableArray<LinePositionSpan>[]? newExceptionRegions)
[In, Out] ActiveStatement[] newActiveStatements,
[In, Out] ImmutableArray<LinePositionSpan>[]? newExceptionRegions)
{
Debug.Assert(oldActiveStatements.Length == newActiveStatements.Length);
Debug.Assert(newExceptionRegions == null || oldActiveStatements.Length == newExceptionRegions.Length);
......@@ -950,11 +950,11 @@ public LambdaInfo WithMatch(Match<SyntaxNode> match, SyntaxNode newLambdaBody)
DocumentId documentId,
IActiveStatementTrackingService? trackingService,
ImmutableArray<ActiveStatement> oldActiveStatements,
[Out]ActiveStatement[] newActiveStatements,
[Out]ImmutableArray<LinePositionSpan>[] newExceptionRegions,
[Out]List<UpdatedMemberInfo> updatedMembers,
[Out]ArrayBuilder<(ActiveStatementId, ActiveStatementTextSpan)> updatedTrackingSpans,
[Out]List<RudeEditDiagnostic> diagnostics)
[Out] ActiveStatement[] newActiveStatements,
[Out] ImmutableArray<LinePositionSpan>[] newExceptionRegions,
[Out] List<UpdatedMemberInfo> updatedMembers,
[Out] ArrayBuilder<(ActiveStatementId, ActiveStatementTextSpan)> updatedTrackingSpans,
[Out] List<RudeEditDiagnostic> diagnostics)
{
Debug.Assert(oldActiveStatements.Length == newActiveStatements.Length);
Debug.Assert(oldActiveStatements.Length == newExceptionRegions.Length);
......@@ -1331,8 +1331,8 @@ public LambdaInfo WithMatch(Match<SyntaxNode> match, SyntaxNode newLambdaBody)
SyntaxNode oldLambdaBody,
SyntaxNode newLambdaBody,
ActiveNode[] activeNodes,
[Out]Dictionary<SyntaxNode, LambdaInfo> activeOrMatchedLambdas,
[Out]List<RudeEditDiagnostic> diagnostics)
[Out] Dictionary<SyntaxNode, LambdaInfo> activeOrMatchedLambdas,
[Out] List<RudeEditDiagnostic> diagnostics)
{
ActiveNode[]? activeNodesInLambda;
if (activeOrMatchedLambdas.TryGetValue(oldLambdaBody, out var info))
......@@ -1680,7 +1680,7 @@ internal TextSpan GetDeletedNodeDiagnosticSpan(IReadOnlyDictionary<SyntaxNode, S
/// <summary>
/// Finds the inner-most ancestor of the specified node that has a matching node in the new tree.
/// </summary>
private static bool TryGetMatchingAncestor(IReadOnlyDictionary<SyntaxNode, SyntaxNode> forwardMap, SyntaxNode? oldNode, [NotNullWhen(true)]out SyntaxNode? newAncestor)
private static bool TryGetMatchingAncestor(IReadOnlyDictionary<SyntaxNode, SyntaxNode> forwardMap, SyntaxNode? oldNode, [NotNullWhen(true)] out SyntaxNode? newAncestor)
{
while (oldNode != null)
{
......@@ -1984,9 +1984,9 @@ private static int IndexOfEquivalent<TSyntaxNode>(SyntaxNode newNode, List<Synta
SourceText newSource,
Match<SyntaxNode> topMatch,
Dictionary<SyntaxNode, EditKind> editMap,
[Out]List<(SyntaxNode OldNode, SyntaxNode NewNode)> triviaEdits,
[Out]List<LineChange> lineEdits,
[Out]List<RudeEditDiagnostic> diagnostics,
[Out] List<(SyntaxNode OldNode, SyntaxNode NewNode)> triviaEdits,
[Out] List<LineChange> lineEdits,
[Out] List<RudeEditDiagnostic> diagnostics,
CancellationToken cancellationToken)
{
foreach (var (oldNode, newNode) in topMatch.Matches)
......@@ -2201,8 +2201,8 @@ public ConstructorEdit(INamedTypeSymbol oldType)
List<UpdatedMemberInfo> updatedMembers,
SemanticModel oldModel,
SemanticModel newModel,
[Out]List<SemanticEdit> semanticEdits,
[Out]List<RudeEditDiagnostic> diagnostics,
[Out] List<SemanticEdit> semanticEdits,
[Out] List<RudeEditDiagnostic> diagnostics,
out Diagnostic? firstDeclarationError,
CancellationToken cancellationToken)
{
......@@ -2853,7 +2853,7 @@ private static bool HasBackingField(IEventSymbol @event)
ref Func<SyntaxNode, SyntaxNode?>? syntaxMap,
ref Dictionary<INamedTypeSymbol, ConstructorEdit>? instanceConstructorEdits,
ref Dictionary<INamedTypeSymbol, ConstructorEdit>? staticConstructorEdits,
[Out]List<RudeEditDiagnostic> diagnostics,
[Out] List<RudeEditDiagnostic> diagnostics,
CancellationToken cancellationToken)
{
if (IsPartial(newType))
......@@ -2912,8 +2912,8 @@ private static bool HasBackingField(IEventSymbol @event)
SemanticModel oldModel,
HashSet<ISymbol> newSymbolsWithEdit,
bool isStatic,
[Out]List<SemanticEdit> semanticEdits,
[Out]List<RudeEditDiagnostic> diagnostics,
[Out] List<SemanticEdit> semanticEdits,
[Out] List<RudeEditDiagnostic> diagnostics,
CancellationToken cancellationToken)
{
foreach (var (newType, update) in updatedTypes)
......@@ -3464,10 +3464,10 @@ private bool TryMapParameter((SyntaxNode? Node, int Ordinal) parameterKey, IRead
ISymbol newMember,
SyntaxNode newMemberBody,
BidirectionalMap<SyntaxNode> map,
[Out]ArrayBuilder<int> reverseCapturesMap, // {new capture index -> old capture index}
[Out]ArrayBuilder<SyntaxNode?> newCapturesToClosureScopes, // {new capture index -> new closure scope}
[Out]ArrayBuilder<SyntaxNode?> oldCapturesToClosureScopes, // {old capture index -> old closure scope}
[Out]List<RudeEditDiagnostic> diagnostics,
[Out] ArrayBuilder<int> reverseCapturesMap, // {new capture index -> old capture index}
[Out] ArrayBuilder<SyntaxNode?> newCapturesToClosureScopes, // {new capture index -> new closure scope}
[Out] ArrayBuilder<SyntaxNode?> oldCapturesToClosureScopes, // {old capture index -> old closure scope}
[Out] List<RudeEditDiagnostic> diagnostics,
out bool hasErrors,
CancellationToken cancellationToken)
{
......
......@@ -23,8 +23,8 @@ internal sealed class EditAndContinueWorkspaceServiceFactory : IWorkspaceService
public EditAndContinueWorkspaceServiceFactory(
IDiagnosticAnalyzerService diagnosticService,
EditAndContinueDiagnosticUpdateSource diagnosticUpdateSource,
[Import(AllowDefault = true)]IActiveStatementProvider activeStatementProvider,
[Import(AllowDefault = true)]IDebuggeeModuleMetadataProvider debugeeModuleMetadataProvider)
[Import(AllowDefault = true)] IActiveStatementProvider activeStatementProvider,
[Import(AllowDefault = true)] IDebuggeeModuleMetadataProvider debugeeModuleMetadataProvider)
{
_diagnosticService = diagnosticService;
_diagnosticUpdateSource = diagnosticUpdateSource;
......
......@@ -25,7 +25,7 @@ internal interface IDebuggeeModuleMetadataProvider
/// <summary>
/// Returns an error message when any instance of a module with given <paramref name="mvid"/> disallows EnC.
/// </summary>
bool IsEditAndContinueAvailable(Guid mvid, out int errorCode, [NotNullWhen(true)]out string localizedMessage);
bool IsEditAndContinueAvailable(Guid mvid, out int errorCode, [NotNullWhen(true)] out string localizedMessage);
/// <summary>
/// Notifies the debugger that a document changed that may affect the given module when the change is applied.
......
......@@ -20,7 +20,7 @@ protected AbstractEmbeddedLanguageFeaturesProvider(EmbeddedLanguageInfo info) :
{
Languages = ImmutableArray.Create<IEmbeddedLanguage>(
new DateAndTimeEmbeddedLanguageFeatures(info),
new RegexEmbeddedLanguageFeatures(this, info),
new RegexEmbeddedLanguage(this, info),
new FallbackEmbeddedLanguage(info));
}
......
......@@ -24,8 +24,8 @@ internal abstract class AbstractRegexDiagnosticAnalyzer : AbstractBuiltInCodeSty
protected AbstractRegexDiagnosticAnalyzer(EmbeddedLanguageInfo info)
: base(DiagnosticId,
RegularExpressionsOptions.ReportInvalidRegexPatterns,
new LocalizableResourceString(nameof(WorkspacesResources.Regex_issue_0), WorkspacesResources.ResourceManager, typeof(WorkspacesResources)),
new LocalizableResourceString(nameof(WorkspacesResources.Regex_issue_0), WorkspacesResources.ResourceManager, typeof(WorkspacesResources)))
new LocalizableResourceString(nameof(FeaturesResources.Regex_issue_0), FeaturesResources.ResourceManager, typeof(FeaturesResources)),
new LocalizableResourceString(nameof(FeaturesResources.Regex_issue_0), FeaturesResources.ResourceManager, typeof(FeaturesResources)))
{
_info = info;
}
......
......@@ -13,7 +13,7 @@ internal partial class RegexEmbeddedCompletionProvider
{
private readonly struct EmbeddedCompletionContext
{
private readonly RegexEmbeddedLanguageFeatures _language;
private readonly RegexEmbeddedLanguage _language;
private readonly CompletionContext _context;
private readonly HashSet<string> _names;
......@@ -24,7 +24,7 @@ internal partial class RegexEmbeddedCompletionProvider
public readonly List<RegexItem> Items;
public EmbeddedCompletionContext(
RegexEmbeddedLanguageFeatures language,
RegexEmbeddedLanguage language,
CompletionContext context,
RegexTree tree,
SyntaxToken stringToken)
......
......@@ -13,7 +13,7 @@
namespace Microsoft.CodeAnalysis.EmbeddedLanguages.RegularExpressions
{
using static WorkspacesResources;
using static FeaturesResources;
/// <summary>
/// Minimal copy of https://github.com/dotnet/corefx/blob/master/src/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexCharClass.cs
......
......@@ -9,7 +9,6 @@
using Microsoft.CodeAnalysis.DocumentHighlighting;
using Microsoft.CodeAnalysis.EmbeddedLanguages.Common;
using Microsoft.CodeAnalysis.EmbeddedLanguages.RegularExpressions;
using Microsoft.CodeAnalysis.EmbeddedLanguages.RegularExpressions.LanguageServices;
using Microsoft.CodeAnalysis.EmbeddedLanguages.VirtualChars;
using Microsoft.CodeAnalysis.Text;
......
......@@ -16,7 +16,7 @@
namespace Microsoft.CodeAnalysis.Features.EmbeddedLanguages.RegularExpressions
{
using static WorkspacesResources;
using static FeaturesResources;
using RegexToken = EmbeddedSyntaxToken<RegexKind>;
internal partial class RegexEmbeddedCompletionProvider : CompletionProvider
......@@ -32,9 +32,9 @@ internal partial class RegexEmbeddedCompletionProvider : CompletionProvider
CompletionItemRules.Default.WithSelectionBehavior(CompletionItemSelectionBehavior.SoftSelection)
.WithFilterCharacterRule(CharacterSetModificationRule.Create(CharacterSetModificationKind.Replace, new char[] { }));
private readonly RegexEmbeddedLanguageFeatures _language;
private readonly RegexEmbeddedLanguage _language;
public RegexEmbeddedCompletionProvider(RegexEmbeddedLanguageFeatures language)
public RegexEmbeddedCompletionProvider(RegexEmbeddedLanguage language)
=> _language = language;
public override bool ShouldTriggerCompletion(SourceText text, int caretPosition, CompletionTrigger trigger, OptionSet options)
......
......@@ -5,22 +5,37 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Classification.Classifiers;
using Microsoft.CodeAnalysis.Completion;
using Microsoft.CodeAnalysis.DocumentHighlighting;
using Microsoft.CodeAnalysis.EmbeddedLanguages.LanguageServices;
using Microsoft.CodeAnalysis.EmbeddedLanguages.RegularExpressions;
using Microsoft.CodeAnalysis.EmbeddedLanguages.RegularExpressions.LanguageServices;
using Microsoft.CodeAnalysis.LanguageServices;
using Microsoft.CodeAnalysis.Shared.Extensions;
namespace Microsoft.CodeAnalysis.EmbeddedLanguages.RegularExpressions.LanguageServices
namespace Microsoft.CodeAnalysis.Features.EmbeddedLanguages.RegularExpressions
{
internal class RegexEmbeddedLanguage : IEmbeddedLanguage
internal class RegexEmbeddedLanguage : IEmbeddedLanguageFeatures
{
public readonly EmbeddedLanguageInfo Info;
private readonly AbstractEmbeddedLanguageFeaturesProvider _provider;
public ISyntaxClassifier Classifier { get; }
public IDocumentHighlightsService DocumentHighlightsService { get; }
public CompletionProvider CompletionProvider { get; }
public RegexEmbeddedLanguage(EmbeddedLanguageInfo info)
public RegexEmbeddedLanguage(
AbstractEmbeddedLanguageFeaturesProvider provider,
EmbeddedLanguageInfo info)
{
Info = info;
Classifier = new RegexSyntaxClassifier(info);
_provider = provider;
DocumentHighlightsService = new RegexDocumentHighlightsService(this);
CompletionProvider = new RegexEmbeddedCompletionProvider(this);
}
internal async Task<(RegexTree tree, SyntaxToken token)> TryGetTreeAndTokenAtPositionAsync(
......@@ -45,5 +60,8 @@ public RegexEmbeddedLanguage(EmbeddedLanguageInfo info)
document, position, cancellationToken).ConfigureAwait(false);
return tree;
}
public string EscapeText(string text, SyntaxToken token)
=> _provider.EscapeText(text, token);
}
}
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using Microsoft.CodeAnalysis.Completion;
using Microsoft.CodeAnalysis.DocumentHighlighting;
using Microsoft.CodeAnalysis.EmbeddedLanguages.LanguageServices;
using Microsoft.CodeAnalysis.EmbeddedLanguages.RegularExpressions.LanguageServices;
namespace Microsoft.CodeAnalysis.Features.EmbeddedLanguages.RegularExpressions
{
internal class RegexEmbeddedLanguageFeatures : RegexEmbeddedLanguage, IEmbeddedLanguageFeatures
{
private readonly AbstractEmbeddedLanguageFeaturesProvider _provider;
public IDocumentHighlightsService DocumentHighlightsService { get; }
public CompletionProvider CompletionProvider { get; }
public RegexEmbeddedLanguageFeatures(
AbstractEmbeddedLanguageFeaturesProvider provider,
EmbeddedLanguageInfo info) : base(info)
{
_provider = provider;
DocumentHighlightsService = new RegexDocumentHighlightsService(this);
CompletionProvider = new RegexEmbeddedCompletionProvider(this);
}
public string EscapeText(string text, SyntaxToken token)
=> _provider.EscapeText(text, token);
}
}
......@@ -21,7 +21,7 @@ internal sealed class VSTypeScriptDiagnosticAnalyzerLanguageService : ILanguageS
[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public VSTypeScriptDiagnosticAnalyzerLanguageService(
[Import(AllowDefault = true)]IVSTypeScriptDiagnosticAnalyzerImplementation? implementation = null)
[Import(AllowDefault = true)] IVSTypeScriptDiagnosticAnalyzerImplementation? implementation = null)
{
Implementation = implementation;
}
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册