Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify defaultRefAssemblies list capacity in AddType.cs #12520

Merged
5 commits merged into from
May 27, 2020

Conversation

xtqqczze
Copy link
Contributor

@xtqqczze xtqqczze commented Apr 29, 2020

PR Summary

  • Clarify calculation of defaultRefAssemblies initial list capacity.
  • Assert if list capacity is increased as a result of a resize.

PR Context

InitDefaultRefAssemblies may initialize a list too small to hold the reference assemblies distributed with netcoreapp5.0, which may result in an expensive reallocation of the internal array.

PR Checklist

Expand `defaultRefAssemblies` initial list capacity to be greater than number of items stored.
@ghost ghost assigned anmenaga Apr 29, 2020
@xtqqczze xtqqczze changed the title Expand defaultRefAssemblies list capacity Expand defaultRefAssemblies list capacity in AddType.cs Apr 29, 2020
@xtqqczze xtqqczze force-pushed the expand-defaultRefAssemblies-list branch from 8db24b3 to 3528365 Compare May 1, 2020 19:19
@xtqqczze xtqqczze changed the title Expand defaultRefAssemblies list capacity in AddType.cs Clarify defaultRefAssemblies list capacity in AddType.cs May 1, 2020
@vexx32
Copy link
Collaborator

vexx32 commented May 4, 2020

Question - is there a way to verify that assertion in a way that can be tested in CI? Debug asserts are great but can cause annoying crashes which seems to be more likely to be a nuisance in a case like this.

Can we add a unit test in C# to verify this instead, so we get a clear test failure without generating broken build artifacts? Doubly so if we're expecting this number to change in future, we should be very careful about using a debug assert here, which will render this functionality entirely unusable in debug builds and I'm not sure will even show up in CI at all.

@iSazonov
Copy link
Collaborator

iSazonov commented May 4, 2020

I guess the value depends only on .Net version and we will catch the exception only after moving to new version and only for local debug builds.

Also we can count refs at design time - see code after # publish reference assemblies in Build.psm1

@ghost ghost added the Review - Needed The PR is being reviewed label May 27, 2020
@ghost
Copy link

ghost commented May 27, 2020

This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Mainainer, Please provide feedback and/or mark it as Waiting on Author

@iSazonov iSazonov added this to the 7.1.0-preview.4 milestone May 27, 2020
@iSazonov iSazonov added CL-CodeCleanup Indicates that a PR should be marked as a Code Cleanup change in the Change Log AutoMerge informs the bot to automerge the PR and removed Review - Needed The PR is being reviewed labels May 27, 2020
@ghost
Copy link

ghost commented May 27, 2020

Hello @iSazonov!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost merged commit 2ea7010 into PowerShell:master May 27, 2020
@xtqqczze xtqqczze deleted the expand-defaultRefAssemblies-list branch May 27, 2020 12:26
ghost pushed a commit that referenced this pull request Jun 2, 2020
# PR Summary

* Increase the list capacity because .NET v5.0.100-preview.5.20278.13 has an extra assembly
* Remove assert added in #12520

## PR Context

HEAD of master has been broken since 99da109 (#12772), when .NET was updated to 5.0.100-preview.5.20278.13

#12815 (comment)

## PR Checklist

- [x] [PR has a meaningful title](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---submission)
    - Use the present tense and imperative mood when describing your changes
- [x] [Summarized changes](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---submission)
- [x] [Make sure all `.h`, `.cpp`, `.cs`, `.ps1` and `.psm1` files have the correct copyright header](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---submission)
- [x] This PR is ready to merge and is not [Work in Progress](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---work-in-progress).
    - If the PR is work in progress, please add the prefix `WIP:` or `[ WIP ]` to the beginning of the title (the `WIP` bot will keep its status check at `Pending` while the prefix is present) and remove the prefix when the PR is ready.
- **[Breaking changes](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#making-breaking-changes)**
    - [x] None
    - **OR**
    - [ ] [Experimental feature(s) needed](https://github.com/MicrosoftDocs/PowerShell-Docs/blob/staging/reference/6/Microsoft.PowerShell.Core/About/about_Experimental_Features.md)
        - [ ] Experimental feature name(s): <!-- Experimental feature name(s) here -->
- **User-facing changes**
    - [x] Not Applicable
    - **OR**
    - [ ] [Documentation needed](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---submission)
        - [ ] Issue filed: <!-- Number/link of that issue here -->
- **Testing - New and feature**
    - [x] N/A or can only be tested interactively
    - **OR**
    - [ ] [Make sure you've added a new test if existing tests do not effectively test the code changed](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#before-submitting)
- **Tooling**
    - [x] I have considered the user experience from a tooling perspective and don't believe tooling will be impacted.
    - **OR**
    - [ ] I have considered the user experience from a tooling perspective and enumerated concerns in the summary. This may include:
        - Impact on [PowerShell Editor Services](https://github.com/PowerShell/PowerShellEditorServices) which is used in the [PowerShell extension](https://github.com/PowerShell/vscode-powershell) for VSCode (which runs in a different PS Host).
        - Impact on Completions (both in the console and in editors) - one of PowerShell's most powerful features.
        - Impact on [PSScriptAnalyzer](https://github.com/PowerShell/PSScriptAnalyzer) (which provides linting & formatting in the editor extensions).
        - Impact on [EditorSyntax](https://github.com/PowerShell/EditorSyntax) (which provides syntax highlighting with in VSCode, GitHub, and many other editors).
@ghost
Copy link

ghost commented Jun 25, 2020

🎉v7.1.0-preview.4 has been released which incorporates this pull request.:tada:

Handy links:

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AutoMerge informs the bot to automerge the PR CL-CodeCleanup Indicates that a PR should be marked as a Code Cleanup change in the Change Log
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants