Avoid a first-chance exception in ReferenceTable.cs when it's clearly not an assembly name
- Dominant language
- C#
- Stars
- 5.5k
- Forks
- 1.5k
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 141
Description
In this RAR stack:
```
> Microsoft.Build.Tasks.Core.dll!Microsoft.Build.Tasks.ReferenceTable.TryConvertToAssemblyName Line 735 C#
Microsoft.Build.Tasks.Core.dll!Microsoft.Build.Tasks.ReferenceTable.SetPrimaryAssemblyReferenceItem Line 540 C#
Microsoft.Build.Tasks.Core.dll!Microsoft.Build.Tasks.ReferenceTable.SetPrimaryItems Line 496 C#
Microsoft.Build.Tasks.Core.dll!Microsoft.Build.Tasks.ReferenceTable.ComputeClosure Line 1635 C#
Microsoft.Build.Tasks.Core.dll!Microsoft.Build.Tasks.ResolveAssemblyReference.Execute Line 2182 C#
Microsoft.Build.Tasks.Core.dll!Microsoft.Build.Tasks.ResolveAssemblyReference.Execute Line 2903 C#
Microsoft.Build.dll!Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute Line 632 C#
```
it is possible that finalName is an absolute or relative file path, such as `..\..\References\VisualStudio\Dev11\Microsoft.Internal.VisualStudio.Shell.Interop.11.0.DesignTime\Microsoft.Internal.VisualStudio.Shell.Interop.11.0.DesignTime.dll`
This code has a try/catch that tries to read it as an assembly name:
`http://source.dot.net/#Microsoft.Build.Tasks.Core/AssemblyDependency/ReferenceTable.cs,735'
It would be quite cheap to check for some invalid chars such as \ : / that can't appear in an assembly name. If any of those chars are present, skip directly to treating the string as a file name.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.