Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
6e03dca
Add the initial roslyn files
CyrusNajmabadi Jun 17, 2022
539b248
Merge remote-tracking branch 'upstream/main' into polyfill
CyrusNajmabadi Jun 17, 2022
e8f0a8e
IN progress
CyrusNajmabadi Jun 17, 2022
1c0fbf2
Builds
CyrusNajmabadi Jun 17, 2022
b533f26
Use api
CyrusNajmabadi Jun 17, 2022
c1a76b1
ifdef
CyrusNajmabadi Jun 17, 2022
2ef0717
Merge remote-tracking branch 'upstream/main' into polyfill
CyrusNajmabadi Jun 20, 2022
1f35a7e
Move using outside namespace
CyrusNajmabadi Jun 20, 2022
f5d8137
Move to debug assert
CyrusNajmabadi Jun 20, 2022
be4ef0f
Optimize common cases
CyrusNajmabadi Jun 20, 2022
2babd86
Merge remote-tracking branch 'upstream/main' into polyfill
CyrusNajmabadi Jun 20, 2022
1cdc428
Explain if'defed regions
CyrusNajmabadi Jun 20, 2022
cfce553
Explain if'defed regions
CyrusNajmabadi Jun 20, 2022
fd9a27e
Update System.Text.RegularExpressions.Generator.csproj
CyrusNajmabadi Jun 21, 2022
e2613b6
Port latest changes over
CyrusNajmabadi Jun 22, 2022
a0e9d88
Merge branch 'polyfill' of https://github.com/CyrusNajmabadi/runtime …
CyrusNajmabadi Jun 22, 2022
91672fe
Renames
CyrusNajmabadi Jun 28, 2022
86de769
Merge branch 'main' into polyfill
CyrusNajmabadi Jun 28, 2022
cc933a2
Update src/libraries/Common/src/Roslyn/CSharpSyntaxHelper.cs
CyrusNajmabadi Jun 28, 2022
8a5a8d0
Simplify
CyrusNajmabadi Jun 28, 2022
4eb00d1
Dispose builders
CyrusNajmabadi Jun 28, 2022
59cdea7
Dispose builders
CyrusNajmabadi Jun 28, 2022
e7a1f3e
Simplify by removing support for nested attributes
CyrusNajmabadi Jun 28, 2022
20d62a2
Simplify
CyrusNajmabadi Jun 28, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ifdef
  • Loading branch information
CyrusNajmabadi committed Jun 17, 2022
commit c1a76b131752bb05f5769ff895d77d8118ea984b
4 changes: 4 additions & 0 deletions src/libraries/Common/src/Roslyn/Hash.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ internal static int Combine(int newKey, int currentKey)
return unchecked((currentKey * (int)0xA5555529) + newKey);
}

#if false
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if i was only referencing a tiny part of the surface area of the copied code, i ifdefed out the rest to keep teh intrusion minimal. i kept the code in case we may need to access more of it. this allows the code to stay close in sync with teh roslyn version.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we please add a comment above explaining this?


internal static int Combine(bool newKeyPart, int currentKey)
{
return Combine(currentKey, newKeyPart ? 1 : 0);
Expand Down Expand Up @@ -373,5 +375,7 @@ internal static int CombineFNVHash(int hashCode, char ch)
{
return unchecked((hashCode ^ ch) * Hash.FnvPrime);
}

#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Roslyn.Utilities;

namespace Microsoft.CodeAnalysis.DotnetRuntime.Extensions;

internal readonly struct GeneratorAttributeSyntaxContext
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Text;
using Microsoft.CodeAnalysis.DotnetRuntime.Extensions;

[assembly: System.Resources.NeutralResourcesLanguage("en-us")]

Expand Down Expand Up @@ -51,7 +52,11 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
context.SyntaxProvider

// Find all MethodDeclarationSyntax nodes attributed with RegexGenerator and gather the required information.
.CreateSyntaxProvider(IsSyntaxTargetForGeneration, GetSemanticTargetForGeneration)
.ForAttributeWithMetadataName(
context,
RegexGeneratorAttributeName,
(n, c) => n is MethodDeclarationSyntax,
GetSemanticTargetForGeneration)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in the future you can delete all the code i've added and this line will now work against the actual ForAttributeWithMetadataName extension we expose. teh only difference is you will also delete the context, argument. That argument is not necessary with our extension because the extension has special access to that data as a private field in the SyntaxProvider type.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lovely

.Where(static m => m is not null)

// Generate the RunnerFactory for each regex, if possible. This is where the bulk of the implementation occurs.
Expand Down