Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix NullReferenceException#9225

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
MiYanni merged 1 commit intomainfromfix-nre
Aug 5, 2025
Merged

Fix NullReferenceException#9225

MiYanni merged 1 commit intomainfromfix-nre
Aug 5, 2025

Conversation

@drewnoakes
Copy link
Member

FirstOrDefault can return null, so it's not safe to dereference unconditionally.

Observed while debugging VS:

System.NullReferenceException: Object reference not set to an instance of an object.Microsoft.TemplateEngine.Orchestrator.RunnableProjects.LocalizationModelDeserializer.LoadPostActionModels.AnonymousMethod__4_4((System.Collections.Generic.IEnumerable<string> NameParts, string LocalizedString) s)System.Linq.Enumerable.WhereSelectEnumerableIterator<(System.Collections.Generic.IEnumerable<string>, string), (System.Collections.Generic.IEnumerable<string>, string)>.MoveNext()System.Linq.Lookup<string, (System.Collections.Generic.IEnumerable<string>, string)>.Create<(System.Collections.Generic.IEnumerable<string>, string)>(System.Collections.Generic.IEnumerable<(System.Collections.Generic.IEnumerable<string>, string)> source, System.Func<(System.Collections.Generic.IEnumerable<string>, string), string> keySelector, System.Func<(System.Collections.Generic.IEnumerable<string>, string), (System.Collections.Generic.IEnumerable<string>, string)> elementSelector, System.Collections.Generic.IEqualityComparer<string> comparer)System.Linq.GroupedEnumerable<(System.Collections.Generic.IEnumerable<string>, string), string, (System.Collections.Generic.IEnumerable<string>, string)>.GetEnumerator()Microsoft.TemplateEngine.Orchestrator.RunnableProjects.LocalizationModelDeserializer.LoadManualInstructionModels(System.Collections.Generic.IEnumerable<(System.Collections.Generic.IEnumerable<string> NameParts, string LocalizedString)> strings)Microsoft.TemplateEngine.Orchestrator.RunnableProjects.LocalizationModelDeserializer.LoadPostActionModels(System.Collections.Generic.List<(string Key, string Value)> localizedStrings)Microsoft.TemplateEngine.Orchestrator.RunnableProjects.LocalizationModelDeserializer.Deserialize(Microsoft.TemplateEngine.Abstractions.Mount.IFile file)Microsoft.TemplateEngine.Orchestrator.RunnableProjects.ScannedTemplateInfo.FindLocalizations()Microsoft.TemplateEngine.Orchestrator.RunnableProjects.ScannedTemplateInfo.ScannedTemplateInfo(Microsoft.TemplateEngine.Abstractions.IEngineEnvironmentSettings settings, Microsoft.TemplateEngine.Abstractions.IGenerator generator, Microsoft.TemplateEngine.Abstractions.Mount.IFile templateFile)Microsoft.TemplateEngine.Orchestrator.RunnableProjects.RunnableProjectGenerator.GetTemplatesFromMountPointInternalAsync(Microsoft.TemplateEngine.Abstractions.Mount.IMountPoint source, System.Threading.CancellationToken cancellationToken) Microsoft.TemplateEngine.Orchestrator.RunnableProjects.RunnableProjectGenerator.Microsoft.TemplateEngine.Abstractions.IGenerator.GetTemplatesFromMountPointAsync(Microsoft.TemplateEngine.Abstractions.Mount.IMountPoint source, System.Threading.CancellationToken cancellationToken)Microsoft.TemplateEngine.Edge.Settings.Scanner.ScanMountPointForTemplatesAsync(Microsoft.TemplateEngine.Edge.Settings.Scanner.MountPointScanSource source, bool logValidationResults, bool returnInvalidTemplates, System.Threading.CancellationToken cancellationToken)Microsoft.TemplateEngine.Edge.Settings.Scanner.ScanAsync(string mountPointUri, System.Threading.CancellationToken cancellationToken)Microsoft.TemplateEngine.Edge.Settings.TemplatePackageManager.UpdateTemplateCacheAsync.AnonymousMethod__2(int index)

`FirstOrDefault` can return null, so it's not safe to dereference unconditionally.Observed while debugging VS:```System.NullReferenceException: Object reference not set to an instance of an object.Microsoft.TemplateEngine.Orchestrator.RunnableProjects.LocalizationModelDeserializer.LoadPostActionModels.AnonymousMethod__4_4((System.Collections.Generic.IEnumerable<string> NameParts, string LocalizedString) s)System.Linq.Enumerable.WhereSelectEnumerableIterator<(System.Collections.Generic.IEnumerable<string>, string), (System.Collections.Generic.IEnumerable<string>, string)>.MoveNext()System.Linq.Lookup<string, (System.Collections.Generic.IEnumerable<string>, string)>.Create<(System.Collections.Generic.IEnumerable<string>, string)>(System.Collections.Generic.IEnumerable<(System.Collections.Generic.IEnumerable<string>, string)> source, System.Func<(System.Collections.Generic.IEnumerable<string>, string), string> keySelector, System.Func<(System.Collections.Generic.IEnumerable<string>, string), (System.Collections.Generic.IEnumerable<string>, string)> elementSelector, System.Collections.Generic.IEqualityComparer<string> comparer)System.Linq.GroupedEnumerable<(System.Collections.Generic.IEnumerable<string>, string), string, (System.Collections.Generic.IEnumerable<string>, string)>.GetEnumerator()Microsoft.TemplateEngine.Orchestrator.RunnableProjects.LocalizationModelDeserializer.LoadManualInstructionModels(System.Collections.Generic.IEnumerable<(System.Collections.Generic.IEnumerable<string> NameParts, string LocalizedString)> strings)Microsoft.TemplateEngine.Orchestrator.RunnableProjects.LocalizationModelDeserializer.LoadPostActionModels(System.Collections.Generic.List<(string Key, string Value)> localizedStrings)Microsoft.TemplateEngine.Orchestrator.RunnableProjects.LocalizationModelDeserializer.Deserialize(Microsoft.TemplateEngine.Abstractions.Mount.IFile file)Microsoft.TemplateEngine.Orchestrator.RunnableProjects.ScannedTemplateInfo.FindLocalizations()Microsoft.TemplateEngine.Orchestrator.RunnableProjects.ScannedTemplateInfo.ScannedTemplateInfo(Microsoft.TemplateEngine.Abstractions.IEngineEnvironmentSettings settings, Microsoft.TemplateEngine.Abstractions.IGenerator generator, Microsoft.TemplateEngine.Abstractions.Mount.IFile templateFile)Microsoft.TemplateEngine.Orchestrator.RunnableProjects.RunnableProjectGenerator.GetTemplatesFromMountPointInternalAsync(Microsoft.TemplateEngine.Abstractions.Mount.IMountPoint source, System.Threading.CancellationToken cancellationToken) Microsoft.TemplateEngine.Orchestrator.RunnableProjects.RunnableProjectGenerator.Microsoft.TemplateEngine.Abstractions.IGenerator.GetTemplatesFromMountPointAsync(Microsoft.TemplateEngine.Abstractions.Mount.IMountPoint source, System.Threading.CancellationToken cancellationToken)Microsoft.TemplateEngine.Edge.Settings.Scanner.ScanMountPointForTemplatesAsync(Microsoft.TemplateEngine.Edge.Settings.Scanner.MountPointScanSource source, bool logValidationResults, bool returnInvalidTemplates, System.Threading.CancellationToken cancellationToken)Microsoft.TemplateEngine.Edge.Settings.Scanner.ScanAsync(string mountPointUri, System.Threading.CancellationToken cancellationToken)Microsoft.TemplateEngine.Edge.Settings.TemplatePackageManager.UpdateTemplateCacheAsync.AnonymousMethod__2(int index)```
@drewnoakesdrewnoakes requested a review froma team as acode ownerAugust 5, 2025 00:34
Copy link
Member

@joeloffjoeloff left a comment

Choose a reason for hiding this comment

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

Is this something we should consider backporting for 8 and 9?

@drewnoakes
Copy link
MemberAuthor

@joeloff I'm not sure. Seems low risk, but I don't know the impact.

I'm not familiar with the merge policy for this repo. Please merge when makes sense.

@MiYanniMiYanni merged commit5c71193 intomainAug 5, 2025
9 checks passed
@MiYanniMiYanni deleted the fix-nre branchAugust 5, 2025 23:47
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@joeloffjoeloffjoeloff approved these changes

@MiYanniMiYanniMiYanni approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@drewnoakes@joeloff@MiYanni

[8]ページ先頭

©2009-2025 Movatter.jp