Skip to content

Documentation & Extensibility#176

Merged
andrew-boyarshin merged 2 commits into
SharpGenTools:masterfrom
andrew-boyarshin:return_of_the_jedi
Feb 9, 2021
Merged

Documentation & Extensibility#176
andrew-boyarshin merged 2 commits into
SharpGenTools:masterfrom
andrew-boyarshin:return_of_the_jedi

Conversation

@andrew-boyarshin

@andrew-boyarshin andrew-boyarshin commented Jan 18, 2021

Copy link
Copy Markdown
Contributor

SharpGenTools.Sdk/Extensibility folder is mostly based on Roslyn. Plus the whole SharpGenTools.Sdk/Internal/Roslyn (the only changes are usings and namespace). Also a couple of minor fixes to the changes in my previous PRs (e.g. Hidden property didn't work), needed to make Vortice.Windows build or be documented.
Note, that there are additional changes required to make Vortice.Windows be built and documented (in all repos).

P.S. I'm not fixing Roslyn code to pass CodeFactor. Perhaps drop the Git hook that requires it to pass?

@andrew-boyarshin

Copy link
Copy Markdown
Contributor Author

I've removed LoggerBase (since it was useless), moved the only interesting method (FormatMessage) to a static LogUtilities class. Then, I've extracted superclass out of Logger, and named it LoggerBase. Since I fucked it up a little (and had little time to fix it), I have these changes in a single commit, so LoggerBase appears to be modified, instead of removed+added in 2 separate commits.

Comment on lines +126 to +134
if (backoffIndex == 5)
{
context.Logger.Message("SharpGen internal invalid state on delay: backoffIndex == 5");
if (Debugger.IsAttached) Debugger.Break();
}
else if (backoffIndex > 5)
{
context.Logger.Message(
$"SharpGen internal invalid state on delay: backoffIndex = {backoffIndex}");
if (Debugger.IsAttached) Debugger.Break();
backoffIndex = 0;
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I kept getting IndexOutOfBoundsException, but couldn't catch it in the debugger. This horrendous block is to assist with debugging, in case it appears again (I stopped hitting it). To be fixed before 2.0 RTW.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Would using First-Chance Exceptions for IndexOutOfBoundsException enable us to break at the exception throw without having to have this workaround? IIRC that exception isn't enabled for first-chance in VS by default.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I use Rider for SharpGen work (but e.g. VS for SharpGen SdkTests, I'm not consistent 😄), AFAIK it doesn't support breaking on first chance exceptions. I simplified the hack code though.

Comment on lines +164 to +170
if (backoffIndex == 5)
{
context.Logger.Message("SharpGen internal invalid state on reschedule: backoffIndex == 5");
if (Debugger.IsAttached) Debugger.Break();
}
else if (backoffIndex > 5)
{
context.Logger.Message($"SharpGen internal invalid state on reschedule: backoffIndex = {backoffIndex}");
if (Debugger.IsAttached) Debugger.Break();
(backoff, backoffIndex, nextDelay) = GenerateBackoff(retryDelay);
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Same as above.

Comment on lines +230 to +232
private static (TimeSpan[] backoff, int index, TimeSpan? nextDelay) GenerateBackoff(TimeSpan offset) =>
// BUG: 5 should be sufficient, but causes IndexOutOfBounds
(Backoff.DecorrelatedJitterBackoffV2(offset + TenthOfSecond, 6).ToArray(), 0, null);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Note that this backoff formula can produce TimeSpans like (mm:ss, for offset = 00:10): 00:11, 00:26, 03:01, 00:48, ....

<PackageReference Include="Microsoft.Bcl.HashCode" />
<PackageReference Include="System.Text.Json" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" />
<PackageReference Include="Polly" />

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Polly is a great project, but feels overengineered and yet still too complex to customize retry/fallback behavior. I dropped the dependency. Polly.Contrib.WaitAndRetry (despite the name) doesn't depend on Polly and provides good exponential backoff formula.

@andrew-boyarshin andrew-boyarshin requested a review from a team February 4, 2021 12:31
@jkoritzinsky

Copy link
Copy Markdown
Member

Why do we need to include internal Roslyn code in our code base?

@andrew-boyarshin

Copy link
Copy Markdown
Contributor Author

Because I didn't want to rewrite complex assembly loading code that was already written and tested in production? Extensibility namespace is highly based on Roslyn code, so, to reuse it, I had to bring the dependencies.

@jkoritzinsky

Copy link
Copy Markdown
Member

That's reasonable.

Can we add a README.md in that folder mentioning that the code is imported from the dotnet/roslyn project?

@andrew-boyarshin

Copy link
Copy Markdown
Contributor Author

@jkoritzinsky I can do that, but only in ~8 hours. I'd like to have this reviewed before that, since README is a minor change.

Comment thread SharpGenTools.Sdk/Extensibility/DefaultExtensionAssemblyLoader.Core.cs Outdated
@andrew-boyarshin

andrew-boyarshin commented Feb 9, 2021

Copy link
Copy Markdown
Contributor Author

@jkoritzinsky Could you drop CodeFactor requirement (that now blocks even force pushes)? It's very annoying and of little use (external code is brought with no modification). Before I disabled that stupid PowerShell check it was always firing on modifications to .ps1 files.

Upd: after a bit of trial, error, adding manual exclusions by file in CodeFactor (globs don't work properly for some reason), force-pushing and stuff, I've managed to merge this. The commit referencing this PR below this very comment is one of the failed attempts, disregard.

andrew-boyarshin added a commit that referenced this pull request Feb 9, 2021
Restore the ability to use external documentation providers, but in a
new way, similar to Roslyn analyzers and source generators.
@andrew-boyarshin andrew-boyarshin merged commit 849d52a into SharpGenTools:master Feb 9, 2021
@andrew-boyarshin andrew-boyarshin deleted the return_of_the_jedi branch February 9, 2021 10:50
@andrew-boyarshin andrew-boyarshin added this to the 2.0 milestone Jun 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants