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

Fix errors due to new ref safety rules. (#169) #181

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

RomainDGx
Copy link

Due to new ref safety rules, three differents errors appears in the NmeaTagBlockParser:

  1. Error CS8347 "Cannot use a result of 'AdvanceToNextField(ref ReadOnlySpan)' in this context because it may expose variables referenced by parameter 'source' outside of their declaration scope".
    To fix this error I had added the scoped keyword in the source parameter as mentioned in Issue Update for new ref safety rules #169

  2. Error CS8350 "This combination of arguments to 'NmeaTagBlockParser.ParseSentenceGrouping(ref ReadOnlySpan)' is disallowed because it may expose variables referenced by parameter 'this' outside of their declaration scope".
    To fix this error I set the method to static and remove this to call the method.

  3. Error CS8352 "Cannot use variable 'remaining' in this context because it may expose referenced variables outside of their declaration scope".
    To fix this error I changed the signature of the GetEnd method. Now the source parameter is no longer in but ref. To resolve the problem of scope, the remaining parameter was removed, then the method directly update the source.
    In ParseDelimitedInt and ParseDelimitedLong I capture the original source to modify the source in GetEnd and use the original source in Utf8Parser.TryParse.

Note: Some generated code are updated when I ran the tests.

This PR fixes the issue #169.

Some generated code are updated when I ran the tests.
@CLAassistant
Copy link

CLAassistant commented Mar 19, 2024

CLA assistant check
All committers have signed the CLA.

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