Prevent DIS from producing invalid statements

This commit is contained in:
Joshua "Yoshi" Askharoun
2025-11-24 02:18:59 -06:00
parent f0f067759a
commit ef2de0a2d1
3 changed files with 74 additions and 8 deletions
+4
View File
@@ -4,6 +4,7 @@ using Microsoft.CodeAnalysis.CSharp.Extensions;
using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.Iris.Asm.Models; using Microsoft.Iris.Asm.Models;
using Microsoft.Iris.Debug.Symbols; using Microsoft.Iris.Debug.Symbols;
using Microsoft.Iris.DecompXml.Extensions;
using Microsoft.Iris.DecompXml.Mock; using Microsoft.Iris.DecompXml.Mock;
using Microsoft.Iris.Markup; using Microsoft.Iris.Markup;
using Microsoft.Iris.Markup.UIX; using Microsoft.Iris.Markup.UIX;
@@ -127,6 +128,9 @@ partial class Decompiler
break; break;
} }
if (!expr.IsStatementExpression())
break;
cfa.AppendToBlock(ExpressionStatement(expr)); cfa.AppendToBlock(ExpressionStatement(expr));
} }
break; break;
@@ -0,0 +1,64 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
namespace Microsoft.Iris.DecompXml.Extensions;
internal static class SyntaxNodeExtensions
{
public static bool IsStatementExpression(this SyntaxNode syntax)
{
// The grammar gives:
//
// expression-statement:
// statement-expression ;
//
// statement-expression:
// invocation-expression
// object-creation-expression
// assignment
// post-increment-expression
// post-decrement-expression
// pre-increment-expression
// pre-decrement-expression
// await-expression
switch (syntax.Kind())
{
case SyntaxKind.InvocationExpression:
case SyntaxKind.ObjectCreationExpression:
case SyntaxKind.SimpleAssignmentExpression:
case SyntaxKind.AddAssignmentExpression:
case SyntaxKind.SubtractAssignmentExpression:
case SyntaxKind.MultiplyAssignmentExpression:
case SyntaxKind.DivideAssignmentExpression:
case SyntaxKind.ModuloAssignmentExpression:
case SyntaxKind.AndAssignmentExpression:
case SyntaxKind.OrAssignmentExpression:
case SyntaxKind.ExclusiveOrAssignmentExpression:
case SyntaxKind.LeftShiftAssignmentExpression:
case SyntaxKind.RightShiftAssignmentExpression:
case SyntaxKind.UnsignedRightShiftAssignmentExpression:
case SyntaxKind.CoalesceAssignmentExpression:
case SyntaxKind.PostIncrementExpression:
case SyntaxKind.PostDecrementExpression:
case SyntaxKind.PreIncrementExpression:
case SyntaxKind.PreDecrementExpression:
case SyntaxKind.AwaitExpression:
return true;
case SyntaxKind.ConditionalAccessExpression:
var access = (ConditionalAccessExpressionSyntax)syntax;
return IsStatementExpression(access.WhenNotNull);
// Allow missing IdentifierNames; they will show up in error cases
// where there is no statement whatsoever.
case SyntaxKind.IdentifierName:
return syntax.IsMissing;
default:
return false;
}
}
}
+6 -8
View File
@@ -272,7 +272,7 @@ ActionContainer.Visible = #SaveAsPlaylistButton.Visible # || #ShowMPContentCheck
]]></Script> ]]></Script>
<Script><![CDATA[ <Script><![CDATA[
[DeclareTrigger(CurrentlyPlayingTrackMixAvailability.Available)] [DeclareTrigger(CurrentlyPlayingTrackMixAvailability.Available)]
object track = zuneUI:TransportControls.Instance.CurrentTrack; zuneUI:PlaybackTrack track = zuneUI:TransportControls.Instance.CurrentTrack;
if ((Page.ShowMixOnEntry && track != null) && (Page.InitialPlaybackID == track.PlaybackID) && #CurrentlyPlayingTrackMixAvailability.Available #) if ((Page.ShowMixOnEntry && track != null) && (Page.InitialPlaybackID == track.PlaybackID) && #CurrentlyPlayingTrackMixAvailability.Available #)
{ {
CurrentlyPlayingTrackMixAvailability.UpdateMixSeed.Invoke(); CurrentlyPlayingTrackMixAvailability.UpdateMixSeed.Invoke();
@@ -670,14 +670,12 @@ if (playingVideo)
{ {
object naturalWidth = stream.ContentHeight * stream.ContentAspectWidth / stream.ContentAspectHeight; object naturalWidth = stream.ContentHeight * stream.ContentAspectWidth / stream.ContentAspectHeight;
object naturalHeight = stream.ContentHeight; object naturalHeight = stream.ContentHeight;
object wndWidth = #Window.ClientSize #.Width; int wndWidth = #Window.ClientSize #.Width;
object wndHeight = Window.ClientSize.Height; int wndHeight = Window.ClientSize.Height;
if (wndWidth != 0 && wndHeight != 0) if (wndWidth != 0 && wndHeight != 0)
{ {
object scaleX = (float)(wndWidth) / (float)(naturalWidth); object scaleX = (float)(wndWidth) / (float)(naturalWidth);
((float)(wndWidth)) / ((float)(naturalWidth));
object scaleY = (float)(wndHeight) / (float)(naturalHeight); object scaleY = (float)(wndHeight) / (float)(naturalHeight);
((float)(wndHeight)) / ((float)(naturalHeight));
int scale = system:Math.Min(scaleX, scaleY); int scale = system:Math.Min(scaleX, scaleY);
maxVideoSizeX = #TransportControls.ZoomScaleFactor # * naturalWidth; maxVideoSizeX = #TransportControls.ZoomScaleFactor # * naturalWidth;
maxVideoSizeY = TransportControls.ZoomScaleFactor * naturalHeight; maxVideoSizeY = TransportControls.ZoomScaleFactor * naturalHeight;
@@ -1320,7 +1318,7 @@ if (ListModel.SelectionManager != null && ListModel.SelectionManager.IsSelected(
<Scripts> <Scripts>
<Script><![CDATA[ <Script><![CDATA[
[DeclareTrigger(zuneUI:TransportControls.Instance.CurrentTrack)] [DeclareTrigger(zuneUI:TransportControls.Instance.CurrentTrack)]
object track = #zuneUI:TransportControls.Instance.CurrentTrack #; zuneUI:PlaybackTrack track = #zuneUI:TransportControls.Instance.CurrentTrack #;
if (LibraryAlbumInfo != null) if (LibraryAlbumInfo != null)
{ {
Class.DisposeOwnedObject(LibraryAlbumInfo); Class.DisposeOwnedObject(LibraryAlbumInfo);
@@ -1513,7 +1511,7 @@ if (RotateInfo.Enabled)
[DeclareTrigger(NowPlayingBackgroundHelper.Visible)] [DeclareTrigger(NowPlayingBackgroundHelper.Visible)]
MPTrackQuery.Enabled = false; MPTrackQuery.Enabled = false;
MPTrackQuery.Id = null; MPTrackQuery.Id = null;
object currentTrack = zuneUI:TransportControls.Instance.CurrentTrack; zuneUI:PlaybackTrack currentTrack = zuneUI:TransportControls.Instance.CurrentTrack;
if (#NowPlayingBackgroundHelper.Visible # && NowPlayingBackgroundHelper.Visible || !currentTrack.IsInVisibleCollection && util:FeatureEnablement.IsFeatureEnabled(zuneDBApi:Features.eMusic)) if (#NowPlayingBackgroundHelper.Visible # && NowPlayingBackgroundHelper.Visible || !currentTrack.IsInVisibleCollection && util:FeatureEnablement.IsFeatureEnabled(zuneDBApi:Features.eMusic))
{ {
MPTrackQuery.Id = TrackId.ToString(); MPTrackQuery.Id = TrackId.ToString();
@@ -1530,7 +1528,7 @@ ArtistQuery.Enabled = false;
ArtistQuery.Id = null; ArtistQuery.Id = null;
TopListenersQuery.Enabled = false; TopListenersQuery.Enabled = false;
TopListenersQuery.ArtistId = null; TopListenersQuery.ArtistId = null;
object currentTrack = zuneUI:TransportControls.Instance.CurrentTrack; zuneUI:PlaybackTrack currentTrack = zuneUI:TransportControls.Instance.CurrentTrack;
if (((!zuneUI:GuidHelper.IsEmpty(ArtistId) && #NowPlayingBackgroundHelper.Visible # && util:FeatureEnablement.IsFeatureEnabled(zuneDBApi:Features.eMusic) && configuration:ClientConfiguration.Playback.ShowNowPlayingClipAnimations) && (iris:Application.RenderingQuality == iris:RenderingQuality.MaxQuality)) && (currentTrack != null) && currentTrack.IsMusic) if (((!zuneUI:GuidHelper.IsEmpty(ArtistId) && #NowPlayingBackgroundHelper.Visible # && util:FeatureEnablement.IsFeatureEnabled(zuneDBApi:Features.eMusic) && configuration:ClientConfiguration.Playback.ShowNowPlayingClipAnimations) && (iris:Application.RenderingQuality == iris:RenderingQuality.MaxQuality)) && (currentTrack != null) && currentTrack.IsMusic)
{ {
ArtistPhotosQuery.Id = ArtistId.ToString(); ArtistPhotosQuery.Id = ArtistId.ToString();